< prev index next >

test/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java

Print this page

        

*** 40,60 **** --- 40,66 ---- * @run main/timeout=300 ChoicePopupLocation */ public final class ChoicePopupLocation { private static final int SIZE = 350; + private static int frameWidth; public static void main(final String[] args) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] sds = ge.getScreenDevices(); Point left = null; + Point right = null; for (GraphicsDevice sd : sds) { GraphicsConfiguration gc = sd.getDefaultConfiguration(); Rectangle bounds = gc.getBounds(); if (left == null || left.x > bounds.x) { left = new Point(bounds.x, bounds.y + bounds.height / 2); } + if (right == null || right.x < bounds.x + bounds.width) { + right = new Point(bounds.x + bounds.width, + bounds.y + bounds.height / 2); + } Point point = new Point(bounds.x, bounds.y); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); while (point.y < bounds.y + bounds.height - insets.bottom - SIZE ) { while (point.x < bounds.x + bounds.width - insets.right - SIZE) {
*** 67,76 **** --- 73,86 ---- } if (left != null) { left.translate(-50, 0); test(left); } + if (right != null) { + right.translate(-frameWidth + 50, 0); + test(right); + } } private static void test(final Point tmp) throws Exception { Choice choice = new Choice(); for (int i = 1; i < 7; i++) {
*** 80,90 **** try { frame.setAlwaysOnTop(true); frame.setLayout(new FlowLayout()); frame.add(choice); frame.pack(); ! frame.setSize(frame.getWidth(), SIZE); frame.setVisible(true); frame.setLocation(tmp.x, tmp.y); openPopup(choice); } finally { frame.dispose(); --- 90,101 ---- try { frame.setAlwaysOnTop(true); frame.setLayout(new FlowLayout()); frame.add(choice); frame.pack(); ! frameWidth = frame.getWidth(); ! frame.setSize(frameWidth, SIZE); frame.setVisible(true); frame.setLocation(tmp.x, tmp.y); openPopup(choice); } finally { frame.dispose();
< prev index next >