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 41159 - menu popups are always displayed on the first monitor
Summary: menu popups are always displayed on the first monitor
Status: REOPENED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: _ ttran
URL:
Keywords: DUAL_MONITOR
: 25383 44259 46470 (view as bug list)
Depends on: 46470
Blocks:
  Show dependency tree
 
Reported: 2004-03-19 20:32 UTC by losmurfs
Modified: 2014-12-11 05:01 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description losmurfs 2004-03-19 20:32:26 UTC
When running on a multi-monitor system, all menus
and context menus always appear on monitor 0
(Primary Display) regardless of which monitor(s)
NetBeans is running on.  Menus and such are being
drawn to monitor relative coordinates on monitor 0
rather than absolute coordinates.
Comment 1 ehucka 2004-03-23 12:29:37 UTC
I think it's window system.
Comment 2 deeptinker 2004-03-24 17:05:51 UTC
Hi,

The dropdown menus still appear on the primary monitor on OSX with RC1
(OS: 10.3.3, Java 1.4.2_04) so this is not just a Windows issue.  It
was supposed to be fixed with
http://www.netbeans.org/issues/show_bug.cgi?id=38375 so maybe that
fixed didn't make it into RC1?

Travis
Comment 3 David Simonek 2004-04-07 13:22:06 UTC
Unfortunately some fixes for dual monitor didn't make it into 3.6.
Comment 4 Marian Mirilovic 2004-06-03 10:46:06 UTC
*** Issue 44259 has been marked as a duplicate of this issue. ***
Comment 5 neilwightman 2004-06-23 09:25:18 UTC
If you use the SDI window system with 3.6 and position windows on both 
monitors.  After exiting netbeans and restarting it, all windows 
appear on the main/first monitor.   

I believe these issues are related to the call to java to get the 
screen dimensions, this only processes the first monitors size.

Toolkit.getDefaultToolkit().getScreenSize()
Comment 6 tkunicki 2004-06-24 21:58:05 UTC
With regards to popup menus and toolbar menu showing up on the primary
display when the main frame is on the secondary display in Windows XP.

I had investigated this issue and found the problem to be the method
overides in the implementations of org.openide.awt.JPopupMenuPlus and
JMenuPlus.  Commenting out the overrides, compiling, jaring and
placing in the lib/locale direcory is a good way to patch the platform
if a quick fix is needed...

The windows dual monitor support is very wacked...  The secondary
display reports positions in the various events that appear to be off
screen relative to the reported display size.  The JPopupMenuPlus and
JMenuPlus implementations try to put the menus "onscreen" which turns
out to be coordinates on the primary display.
Comment 7 Jesse Glick 2004-08-17 04:21:29 UTC
1. Should probably be assigned to Tim; he is the one likely to be
fixing JPopupMenuPlus and its evil brethren.

2. Probably too late for 4.0.
Comment 8 wensveen 2004-08-17 08:50:18 UTC
I think this is a duplicate of bug 25383
Comment 9 _ tboudreau 2004-08-17 12:41:14 UTC
There already is a workaround - start NetBeans with 

-J-Dnetbeans.popup.no_hack=true

This is not on by default, because it can cause menus to "flash" (be
redisplayed several times when they are shown) - which is due to some
very old and hard to remove hacks (JInlineMenu and its evil brethren).
Comment 10 wensveen 2004-08-17 13:18:15 UTC
The workaround works pretty good for me. Maybe this can be a
configuration option or something? But thanks anyway, this makes
working with netbeans on my system a lot easier...
Comment 11 wensveen 2004-08-17 13:19:50 UTC
BTW, even with the workaround, tooltips are still displayed on the
wrong screen.
Comment 12 _ tboudreau 2004-08-17 13:58:35 UTC
I don't think we do anything special with tooltip placement - NetBeans
doesn't replace the default tooltip manager to my knowledge, so that's
probably a JDK bug.  What JDK are you using?  If not 1.5, does it work
right in 1.5?
Comment 13 _ tboudreau 2004-08-30 11:46:10 UTC
More relevant question:  If you create a generic Swing app (say a form with a button that 
has a long tooltip), does the tooltip show up on the correct monitor?

If it does not, it's a Swing bug (the fix will probably be in PopupFactory), but might be able 
to be worked around if we wanted to provide our own version of PopupFactory.  It 
*should* be detectable if there is more than one display device.
Comment 14 wensveen 2004-09-06 07:51:52 UTC
I will try out as soon as I have multiple monitors available again. I
am currently outsourced, and the buggers only have one monitor :(
Comment 15 David Simonek 2004-09-06 11:16:48 UTC
Passing to Trung at his request.
Comment 16 deeptinker 2004-09-06 17:37:45 UTC
With the 200409022120 build, the tooltips now appear on the correct
monitor, regardless of the "nohack" option.  With the "nohack" option
the menus and contextual menus also appear on the apppropriate
monitor.  The only odd behaviour I found was that secondary dialog
boxes appear on the main monitor rather than the monitor containing
the primary dialog box.

Travis
Comment 17 _ ttran 2004-09-07 15:41:43 UTC
*** Issue 47719 has been marked as a duplicate of this issue. ***
Comment 18 _ ttran 2004-09-07 15:42:29 UTC
*** Issue 46470 has been marked as a duplicate of this issue. ***
Comment 19 _ ttran 2004-09-07 15:43:33 UTC
*** Issue 25383 has been marked as a duplicate of this issue. ***
Comment 20 _ ttran 2004-09-07 15:45:45 UTC
updated summary
Comment 21 _ ttran 2004-09-07 16:26:50 UTC
AWT since 1.3 provides multiple-monitor support API.  We can fix this
bug reliably, no need to hack
Comment 22 _ ttran 2004-09-07 16:33:50 UTC
fixed

1.18        JPopupMenuUtils.java
Comment 23 David Strupl 2004-09-08 12:15:39 UTC
You should fix also JMenuPlus.java and JPopupMenuPlus.java and
completely remove the flag:
Boolean.getBoolean("netbeans.popup.no_hack");
If you succeed please update also the API documents since I have
mentioned the flag there also.

I am willing to do some testing on my dual monitor machine if you are
interested ;-)
Comment 24 _ ttran 2004-09-08 12:28:06 UTC
both JMenuPlus.java and JPopupMenuPlus.java  call into
JPopupMenuUtils.java.  It works correctly for my dual monitor setup,
both windows and linux.  Can you please verify, take the latest
nightly or build the IDE from the CVS trunk 

I'll wait for verification before removing your hack
Comment 25 _ tboudreau 2004-09-08 12:48:17 UTC
Note also

d-eprg05-75-206:/space/nb_another/core/windows tim$ grep -r "no_hack" *
src/org/netbeans/core/windows/view/ui/slides/CommandManager.java:     private static 
final boolean NO_POPUP_PLACEMENT_HACK = 
Boolean.getBoolean("netbeans.popup.no_hack"); // NOI18N
src/org/netbeans/core/windows/view/ui/TabbedHandler.java:    private static final 
boolean NO_POPUP_PLACEMENT_HACK = Boolean.getBoolean("netbeans.popup.no_hack"); 
// NOI18N
d-eprg05-75-206:/space/nb_another/core/windows tim$ grep -r "NO_POPUP" *
src/org/netbeans/core/windows/view/ui/slides/CommandManager.java:     private static 
final boolean NO_POPUP_PLACEMENT_HACK = 
Boolean.getBoolean("netbeans.popup.no_hack"); // NOI18N
src/org/netbeans/core/windows/view/ui/slides/CommandManager.java:        if 
(NO_POPUP_PLACEMENT_HACK) {
src/org/netbeans/core/windows/view/ui/TabbedHandler.java:    private static final 
boolean NO_POPUP_PLACEMENT_HACK = Boolean.getBoolean("netbeans.popup.no_hack"); 
// NOI18N
src/org/netbeans/core/windows/view/ui/TabbedHandler.java:        if 
(NO_POPUP_PLACEMENT_HACK) {
Comment 26 David Strupl 2004-09-08 13:22:03 UTC
Hehe, it was not my hack. I just added the option to actually disable
some strange hacks (by Evan Adams BTW).
Comment 27 David Strupl 2004-09-28 14:32:36 UTC
Sorry it took so long. I have now verified that it works correctly 
using build number 200409221800 on my dual monitor WinXP box. There 
was no need to specify the command line option. If someone have time 
for this the command line option can be removed from all the places.
Comment 28 Quality Engineering 2008-12-23 14:29:48 UTC
This issue had *1 votes* before move to platform component
Comment 29 ayantikap 2014-12-11 05:01:17 UTC
Hi All,

I need an immediate help from you all regarding my problem . It describes as below :

The below are my use cases :

1. JDK 7 used.

2. OS - Ubuntu/windows XP/2008

3. A java swing built-up swing portal application is causing the issue.

4. Tested with extending more than 1 monitors, i.e. Laptop / primary monitors are attached with other secondary monitors attached and then running swing portal        application.

4. This happens when you use "Extended Desktop" with two screens.

    Main screen left

    Second screen right

    Portal is visible on two screens.

    Open a context menu (right mouse) on the right screen, the context menu open on the left (Main) screen instead of the right

 

 

The below is the sample of code of the file that actually open up the popups. The bold italics methods are the call hierarchy that are responsible to finally call the showPopupMenu().

 

private synchronized void handleMouseEvent( final IDirNodeMouseEvent e ) {

        if ( e.getMEvent().isPopupTrigger() ) {

            Thread thread = new Thread(

                    new Runnable() {

                        public void run() {

                            JNDITreeNode node = (JNDITreeNode) e.getNodeAtEventLocation();

                            System.out.println(" --- handleMouseEvent ---");

                            createPopupMenu(e.getMEvent().getPoint(), e.getMEvent().getComponent(), node);

                        }       

                    }

            );

            thread.start();

        }

 

private synchronized void createPopupMenu(final Point point, final Component c, JNDITreeNode node) {

        contextMenuDN = node.getDn();

        CursorHelper cursorHelper = CursorHelper.showWaitCursor(c);

        com.marconi.platform.cvb.bcmp.security.AbstractDNPanel.registerJndiTreeNode(node);

        ContextMenuFactory contextMenuFactory = new ContextMenuFactory ( context );

        contextMenuFactory.setAttributeViewDisplayText(node.getDisplayText());

        TreeNodeDescriptor treeNodeDescriptor = new TreeNodeDescriptor(

                node.getDn(),

                node.getDirData()

        );

      

        boolean searchContextAvailable = true;

        JNDIData data = node.getDirData();

        Attributes attrs = data.getAttributes();

        Attribute a = attrs.get("mSearchContextAvailable");

        try

        {

          if (a != null)

            {

                String value = (String)a.get();

                if (value.equalsIgnoreCase("FALSE"))

                    searchContextAvailable = false;

            }

        }

        catch (NamingException ne)

        { }

        jMenuItemSearch.setEnabled(searchContextAvailable);

        JPopupMenu menu = contextMenuFactory.getPopupContextMenu( treeNodeDescriptor );

        menu.addSeparator();

        menu.add( jMenuItemCollapseAll );

        menu.add( jMenuItemSearch );

        if ( contextMenuDN != null ) {

            menu.add(jMenuItemUpdate);

        }

        MUtils.showPopupMenu(menu, point, c);

        cursorHelper.showDefaultCursor();

    }

 

/**

   * MUtils ensures that the whole popup menu is visible, performs a cleanup before showing.

   * @param popupMenu the menu to be shown

   * @param mouseClickPoint where the mouse has been clicked

   * @param c the component on which to show the popup menu

   * @see cleanupMenu

   */

    public static void showPopupMenu( final JPopupMenu popupMenu, final Point mouseClickPoint, final Component c) {

    if ( popupMenu.getComponentCount() == 0 ) return;

   

    cleanupMenu( popupMenu );

    if ( autoAssigningMnemonics ) {

      assignMnemonics( popupMenu );

    }

   

    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

   

    final Point result = new Point(mouseClickPoint);

    SwingUtilities.convertPointToScreen( result, c);

   

    Dimension popupSize = popupMenu.getPreferredSize();

    popupSize.height = popupSize.height + 30; // as Windows TaskBar is overlapping always

  

      if ( popupSize != null ) {

      if ( result.getX() + popupSize.getWidth() > screenSize.getWidth() ) {

        result.setLocation( screenSize.getWidth() - popupSize.getWidth() , result.getY() );

      }

      if ( result.getY() + popupSize.getHeight() > screenSize.getHeight() ) {

        result.setLocation( result.getX(), screenSize.getHeight() - popupSize.getHeight() );

      }

    }

 

    result.x = Math.max( 0, result.x );

    result.y = Math.max( 0, result.y );

 

    SwingUtilities.convertPointFromScreen( result, c );

    javax.swing.SwingUtilities.invokeLater(

      new Runnable() {

        public void run() {

            popupMenu.show( c, (int) result.getX(), (int) result.getY());

        }

      }

    );

}

 

 

Please let me know how to resolve it !!!