This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 133235

Summary: Dialogs API Should Center in Application, not in Screen
Product: platform Reporter: tomwheeler <tomwheeler>
Component: Dialogs&WizardsAssignee: Stanislav Aubrecht <saubrecht>
Status: RESOLVED FIXED    
Severity: blocker CC: anebuzelsky, jrechtacek, lhasik, olangr
Priority: P3 Keywords: UI
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: prototype core.windows to platform9/modules

Description tomwheeler 2008-04-18 19:34:09 UTC
Dialogs created using the Dialogs API are automatically centered, but are centered within the entire screen rather than
within the application that generated them.  It would be more consistent with the behavior of other applications if it
was centered within the application's main window and would also make it more obvious which application generated the
dialog when multiple applications are running simultaneously.

To reproduce, launch the IDE and resize it to take up only the upper-right 10% of the screen.  Click the File menu and
then choose "New Project..." and you will see the dialog lies outside of the application window.  Similar behavior can
be observed on any platform-based application that uses the Dialogs API and its default implementation.

Line 236 in NbPresenter.java (in 6.0 final sources) calls setBounds, passing the calculated center of the screen.
   
   setBounds(Utilities.findCenterBounds(getSize()));

I think it would be preferable to replace this with something like the following.

   setLocationRelativeTo(getParent());

This will basically center on the parent if it's not null, and center on the screen otherwise. 

If a change in the default behavior is not possible, we'd appreciate knowing how to change it locally without patching
source code or mostly duplicating the default Dialogs API implementation which is otherwise OK.
Comment 1 Jiri Rechtacek 2008-04-19 08:54:17 UTC
It should consult it with UI team before changing behavior what it is in NetBeans for ages. 
Comment 2 tomwheeler 2008-04-19 22:31:39 UTC
Maybe an easy alternative is that the default behavior remains the same and dialogs will be centered above the application window only if some system 
property is set.  This would maintain compatibility, be easy to implement and satisfy people who need either behavior.
Comment 3 Jiri Rechtacek 2008-04-24 10:54:36 UTC
Jano, could you please look on this problem? AFAIK, all NetBeans dialogs what are just simple using Openide Dialogs API
are centered in screen. But for example Open Project dialog is centered in Application (I suppose it handle it itself)
it should be uniform. Any thoughts? What might be better? Thanks
Comment 4 jrojcek 2008-09-01 09:55:27 UTC
I briefly checked other apps on Win XP and there doesn't seem to be a standard behavior. I can imagine users using NetBeans IDE on very big monitors where 
NB window takes only part on the whole screen. In such setup it's probably better if dialogs popup above the NetBeans window, not centered on the screen. 
Similarly for apps built on top of NetBeans.

So yes, centering in NetBeans may be better.

Just note that there are users who two monitors next to each other as a single virtual screen and NetBeans is expanded through the whole area cross both 
monitors. In such case a dialog box has to open centered on the primary monitor, not in NetBeans window as it would open right cross the connection of two 
monitors and become unusable.
Comment 5 tomwheeler 2008-09-01 20:36:14 UTC
jrojcek makes some good observations. The developer who originally brought this to my attention has a huge monitor (24"
LCD).  I have two 21" monitors as a single desktop both at home and work.
Comment 6 Jiri Rechtacek 2008-09-10 17:07:50 UTC
The suggestion can work but I'm not sure it's good time for such UI changes now. I'm familiar with current centering in
screen and when I was trying center in application it had effect a bad surprise to me. What about to post-pone this
after NB6.5? Anyway, it should be tracked as late UI change in NB6.5 I have lack of justification for such change IMHO.
I'm going to remove fix-in-65 from whiteboard.
Comment 7 tomwheeler 2008-09-10 17:13:52 UTC
I am the original reporter.  It is OK with me to postpone for 6.5 but IMHO it should definitely be considered for post 
6.5.
Comment 8 Jiri Rechtacek 2008-09-11 09:24:36 UTC
Created attachment 69620 [details]
prototype core.windows to platform9/modules
Comment 9 Jiri Rechtacek 2008-09-11 09:28:47 UTC
I found out it works incorrectly if I undock some tab out of IDE main window. In that case new dialogs are centering
still in main window instead of undocked tab. I attached core/windows jar using this proposal for playing with it. But I
still don't think it could be fixed in NB6.5
Comment 10 Antonin Nebuzelsky 2008-09-26 12:46:01 UTC
> don't think it could be fixed in NB6.5

Removing "fix-in-65".
Comment 11 Jiri Rechtacek 2008-11-21 16:19:41 UTC
It's RFE currently tracked in NB7.0 plan.
Comment 12 Stanislav Aubrecht 2013-04-23 13:45:15 UTC
core-main d339423bdff2
Comment 13 Quality Engineering 2013-04-28 02:18:25 UTC
Integrated into 'main-golden', will be available in build *201304272301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/d339423bdff2
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #133235 - open dialogs centered on the main app window