[hg] main-silver: #228729: trying to get the correct screen boun...

  • From: Jan Lahoda < >
  • To:
  • Subject: [hg] main-silver: #228729: trying to get the correct screen boun...
  • Date: Fri, 26 Apr 2013 16:47:15 -0700

changeset d0b42d846791 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/d0b42d846791
description:
        #228729: trying to get the correct screen bounds by enumerating all 
devices

diffstat:

 spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java |  32 
++++++---
 1 files changed, 21 insertions(+), 11 deletions(-)

diffs (71 lines):

diff --git 
a/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java 
b/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java
--- a/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java
+++ b/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java
@@ -50,6 +50,9 @@
 import java.awt.Container;
 import java.awt.Cursor;
 import java.awt.Dimension;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.HeadlessException;
 import java.awt.Point;
 import java.awt.Rectangle;
@@ -307,12 +310,12 @@
 
 //        SwingUtilities.convertPointToScreen(p, comp);
 
-        Dimension maxSize = Toolkit.getDefaultToolkit().getScreenSize();
+        Rectangle maxSize = getScreenBounds();
         maxSize.width -= p.x;
         maxSize.height -= p.y;
 
         subhintListComponent =
-                new ScrollCompletionPane(comp, new 
FixData(ErrorDescriptionFactory.lazyListForFixes(ff), 
ErrorDescriptionFactory.lazyListForFixes(Arrays.<Fix>asList())), null, null, 
maxSize);
+                new ScrollCompletionPane(comp, new 
FixData(ErrorDescriptionFactory.lazyListForFixes(ff), 
ErrorDescriptionFactory.lazyListForFixes(Arrays.<Fix>asList())), null, null, 
new Dimension(maxSize.width, maxSize.height));
 
         subhintListComponent.getView().addMouseListener (this);
         subhintListComponent.getView().addMouseMotionListener(this);
@@ -355,11 +358,11 @@
             Point p = new Point (r.x + 5, r.y + 20);
             SwingUtilities.convertPointToScreen(p, comp);
             
-            Dimension maxSize = Toolkit.getDefaultToolkit().getScreenSize();
+            Rectangle maxSize = getScreenBounds();
             maxSize.width -= p.x;
             maxSize.height -= p.y;
             hintListComponent = 
-                    new ScrollCompletionPane(comp, hints, null, null, 
maxSize);
+                    new ScrollCompletionPane(comp, hints, null, null, new 
Dimension(maxSize.width, maxSize.height));
 
             hintListComponent.getView().addMouseListener (this);
             hintListComponent.getView().addMouseMotionListener(this);
@@ -502,14 +505,21 @@
     }
 
     private Rectangle getScreenBounds() throws HeadlessException {
-        JTextComponent comp = getComponent();
-        Rectangle screenBounds = null;
-        if (null != comp && null != comp.getGraphicsConfiguration()) {
-            screenBounds = comp.getGraphicsConfiguration().getBounds();
-        } else {
-            screenBounds = new 
Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
+      Rectangle virtualBounds = new Rectangle();
+      GraphicsEnvironment ge = 
GraphicsEnvironment.getLocalGraphicsEnvironment();
+      GraphicsDevice[] gs = ge.getScreenDevices();
+
+      if (gs.length == 0) return new 
Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
+
+      for (int j = 0; j < gs.length; j++) {
+          GraphicsDevice gd = gs[j];
+          GraphicsConfiguration[] gc = gd.getConfigurations();
+          for (int i=0; i < gc.length; i++) {
+              virtualBounds = virtualBounds.union(gc[i].getBounds());
         }
-        return screenBounds;
+      }
+
+      return virtualBounds;
     }
 
     private int getUsableWidth(JTextComponent component) {

[hg] main-silver: #228729: trying to get the correct screen boun...

Jan Lahoda 04/26/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close