Java Code Examples for javax.swing.JWindow#getSize()
The following examples show how to use
javax.swing.JWindow#getSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DropDownTextFieldTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testDropdownLocationOnResize() { // insert some text and make sure the window is created typeText("d", true); JWindow matchingWindow = textField.getActiveMatchingWindow(); Dimension windowSize = matchingWindow.getSize(); Dimension size = parentFrame.getSize(); Dimension newSize = new Dimension(size.width - 50, size.height); runSwing(() -> parentFrame.setSize(newSize)); waitForSwing(); // we have to wait here; it seems like that there may be an 'invokeLater' happening // in the Swing components waitForCondition(() -> !windowSize.equals(matchingWindow.getSize()), "The completion window's size did not update when its parent window was resized."); }
Example 2
Source File: DropDownTextFieldTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testSetMatchingWindowHeight() { int newSize = 200; runSwing(() -> textField.setMatchingWindowHeight(newSize)); waitForSwing(); typeText("d", true); JWindow matchingWindow = textField.getActiveMatchingWindow(); Dimension windowSize = matchingWindow.getSize(); assertEquals(newSize, windowSize.height); }
Example 3
Source File: DropDownTextFieldTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testSetMatchingWindowHeight_MatchingWindowOpen() { typeText("d", true); int newSize = 200; runSwing(() -> textField.setMatchingWindowHeight(newSize)); waitForSwing(); JWindow matchingWindow = textField.getActiveMatchingWindow(); Dimension windowSize = matchingWindow.getSize(); assertEquals(newSize, windowSize.height); }
Example 4
Source File: TooltipWindow.java From netbeans with Apache License 2.0 | 5 votes |
public void show(Point location) { Rectangle screenBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice device : gds) { GraphicsConfiguration gc = device.getDefaultConfiguration(); screenBounds = gc.getBounds(); if (screenBounds.contains(location)) { break; } } // showing the popup tooltip cp = new TooltipContentPanel(master.getTextComponent()); Window w = SwingUtilities.windowForComponent(master.getTextComponent()); contentWindow = new JWindow(w); contentWindow.add(cp); contentWindow.pack(); Dimension dim = contentWindow.getSize(); if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) { dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER); } if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) { dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER); } contentWindow.setSize(dim); contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment contentWindow.setVisible(true); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); w.addWindowFocusListener(this); contentWindow.addWindowFocusListener(this); }
Example 5
Source File: TooltipWindow.java From netbeans with Apache License 2.0 | 5 votes |
public void show(Point location) { Rectangle screenBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice device : gds) { GraphicsConfiguration gc = device.getDefaultConfiguration(); screenBounds = gc.getBounds(); if (screenBounds.contains(location)) { break; } } // showing the popup tooltip cp = new TooltipContentPanel(master.getTextComponent()); Window w = SwingUtilities.windowForComponent(master.getTextComponent()); contentWindow = new JWindow(w); contentWindow.add(cp); contentWindow.pack(); Dimension dim = contentWindow.getSize(); if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) { dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER); } if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) { dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER); } contentWindow.setSize(dim); contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment contentWindow.setVisible(true); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); w.addWindowFocusListener(this); contentWindow.addWindowFocusListener(this); }
Example 6
Source File: TooltipWindow.java From netbeans with Apache License 2.0 | 5 votes |
public void show(Point location) { Rectangle screenBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice device : gds) { GraphicsConfiguration gc = device.getDefaultConfiguration(); screenBounds = gc.getBounds(); if (screenBounds.contains(location)) { break; } } // showing the popup tooltip cp = new TooltipContentPanel(master.getTextComponent()); Window w = SwingUtilities.windowForComponent(master.getTextComponent()); contentWindow = new JWindow(w); contentWindow.add(cp); contentWindow.pack(); Dimension dim = contentWindow.getSize(); if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) { dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER); } if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) { dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER); } contentWindow.setSize(dim); contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment contentWindow.setVisible(true); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); w.addWindowFocusListener(this); contentWindow.addWindowFocusListener(this); }
Example 7
Source File: MsgTooltipWindow.java From netbeans with Apache License 2.0 | 4 votes |
void show(Point location) { Rectangle screenBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice device : gds) { GraphicsConfiguration gc = device.getDefaultConfiguration(); screenBounds = gc.getBounds(); if (screenBounds.contains(location)) { break; } } // showing the popup tooltip cp = new TooltipContentPanel(); Window w = SwingUtilities.windowForComponent(parent); contentWindow = new JWindow(w); contentWindow.add(cp); contentWindow.pack(); Dimension dim = contentWindow.getSize(); if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) { // the whole window does fully not fit to the right // the x position where the window has to start to fully fit to the right int left = screenBounds.width + screenBounds.x - cp.longestLine; // the window should have x pos minimally at the screen's start location.x = Math.max(screenBounds.x, left); } if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) { dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER); } if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) { dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER); } contentWindow.setSize(dim); contentWindow.setLocation(location.x, location.y + 1); // slight visual adjustment contentWindow.setVisible(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { cp.scrollRectToVisible(new Rectangle(1, 1)); } }); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); w.addWindowFocusListener(this); contentWindow.addWindowFocusListener(this); contentWindow.addKeyListener(this); w.addKeyListener(this); }