javax.swing.JWindow Java Examples

The following examples show how to use javax.swing.JWindow. 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: DropDownSelectionTextFieldTest.java    From ghidra with Apache License 2.0 7 votes vote down vote up
@Test
public void testEscapeKey_MatchingWindowOpen() {

	typeText("d", true);

	String item = getSelectedListItem();

	// hide the window without updating the contents of the text field
	escape();

	JWindow matchingWindow = textField.getActiveMatchingWindow();
	assertTrue("The selection window is still showing after cancelling editing.",
		!matchingWindow.isVisible());
	assertNotEquals("Cancelling the completion window incorrectly updated the contents " +
		"of the text field with the selected item in the list.", item, textField.getText());
	assertNoEditingCancelledEvent();
}
 
Example #2
Source File: MesquiteFileDialog.java    From MesquiteCore with GNU Lesser General Public License v3.0 6 votes vote down vote up
public MesquiteFileDialog (MesquiteWindow f, String message, int type) {
	super(getFrame(f), message, type);
	if (type == FileDialog.LOAD &&  (MesquiteTrunk.isMacOS() || MesquiteTrunk.isMacOSX()) && MesquiteTrunk.getOSXVersion()>10){
		titleWindow = new JWindow(); 
		titleWindow.setSize(twWidth,twHeight);
		titleWindowLabel = new Label();
		titleWindowLabel.setBackground(ColorDistribution.veryLightYellow); //ColorTheme.getExtInterfaceBackground()); //ColorDistribution.veryLightGray
		titleWindow.add(titleWindowLabel);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int v, h;
		h = (screenSize.width-twWidth)/2;
		v = 26;
		titleWindow.setLocation(h, v);
		titleWindowLabel.setText("  " + message);
	//	Color darkBlue = new Color((float)0.0, (float)0.0, (float)0.7);
		titleWindowLabel.setForeground(ColorDistribution.darkBlue); //ColorTheme.getExtInterfaceElement(true));

	}
	this.message = message;
	this.type = type;
	currentFileDialog = this;
	//mfdThread = new MFDThread(this);
	//mfdThread.start();
	MainThread.incrementSuppressWaitWindow();
}
 
Example #3
Source File: MorePropertySheetTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSetNodesSurvivesMultipleAdd_RemoveNotifyCalls() throws Exception {
    final PropertySheet ps = new PropertySheet();
    Node n = new AbstractNode( Children.LEAF );
    JWindow window = new JWindow();
    ps.setNodes( new Node[] {n} );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.setVisible(true);
    assertNotNull(ps.helperNodes);
    assertEquals("Helper nodes are still available even after several addNotify()/removeNotify() calls",
            ps.helperNodes[0], n);
}
 
Example #4
Source File: QPopup.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * Create a transparent window
 */
protected JWindow createWindow() {
	JWindow window = new JWindow();
	window.getRootPane().putClientProperty(PROPERTY_IS_QPOPUP, true);
	window.setType(Type.POPUP);
	window.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
	float k = .95f;
	window.getRootPane().putClientProperty("Window.opacity", k);
	window.setOpacity(k);
	window.setBackground(new Color(0, 0, 0, 0));
	window.getRootPane().setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;
	window.getRootPane().add(contents, c);
	return window;
}
 
Example #5
Source File: SequentialNotificationManager.java    From 07kit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * shows the next window on the stack
 */
private static void nextWindow() {
	try {
		sLock.lock();
		if(!sWindowOpen && sWindows.size() > 0) {
			sWindowOpen = true;
			final JWindow window = sWindows.removeFirst();
			Timer delayVisibleTimer = new Timer(DELAY, new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					final Timer t = (Timer) e.getSource();
					t.stop();
					window.setVisible(true);
					window.getGlassPane().setVisible(true);

				}
			});
			delayVisibleTimer.start();
		}
	} finally {
		sLock.unlock();
	}
}
 
Example #6
Source File: SequentialNotificationManager.java    From 07kit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Shows the notification
 * @param window window to show
 */
protected static void showNotification(final JWindow window) {
	try {
		sLock.lock();
		sWindows.addLast(window);
		window.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent e) {
				window.removeWindowListener(this);
				sWindowOpen = false;
				nextWindow();
			}
		});
		nextWindow();
	} finally {
		sLock.unlock();
	}
}
 
Example #7
Source File: JemmyExt.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static JWindow getJWindow(int index) {
    return new QueueTool().invokeAndWait(new QueueTool.QueueAction<JWindow>(null) {

        @Override
        public JWindow launch() throws Exception {
            Window[] windows = Window.getWindows();
            int windowIndex = 0;
            for (Window w : windows) {
                if (w.getClass().equals(JWindow.class)) {
                    if (windowIndex == index) {
                        return (JWindow) w;
                    }
                    windowIndex++;
                }
            }
            return null;
        }
    });
}
 
Example #8
Source File: JemmyExt.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static int getJWindowCount() {
    return new QueueTool().invokeAndWait(new QueueTool.QueueAction<Integer>(null) {

        @Override
        public Integer launch() throws Exception {
            Window[] windows = Window.getWindows();
            int windowCount = 0;
            for (Window w : windows) {
                if (w.getClass().equals(JWindow.class)) {
                    windowCount++;
                }
            }
            return windowCount;
        }
    });
}
 
Example #9
Source File: TranslucentPopupFactory.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
 * Frees any resources the <code>Popup</code> may be holding onto.
 */
protected void dispose()
{
	Component component = getComponent();
	Window window = SwingUtilities.getWindowAncestor(component);

	if (component instanceof JWindow)
	{
		((Window) component).dispose();
		component = null;
	}
	// If our parent is a DefaultFrame, we need to dispose it, too.
	if (window instanceof DefaultFrame)
	{
		window.dispose();
	}
}
 
Example #10
Source File: MPCMaid.java    From mpcmaid with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void showSplash() {
	screen = new JWindow();
	final URL resource = MainFrame.class.getResource("mpcmaidlogo400_400.png");
	final JLabel label = new JLabel(new ImageIcon(resource));
	screen.getContentPane().add(label);
	screen.setLocationRelativeTo(null);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension labelSize = screen.getPreferredSize();
	screen
			.setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2
					- (labelSize.height / 2));
	screen.pack();
	screen.setVisible(true);
	label.repaint();
	screen.repaint();
}
 
Example #11
Source File: DropDownSelectionTextFieldTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testSelectionFromWindowByClicking() {

	typeText("d", true);

	JList<String> dataList = textField.getJList();
	String selected = getSelectedListItem();

	// fire a mouse click into the window
	Point clickPoint = dataList.indexToLocation(dataList.getSelectedIndex());
	clickMouse(dataList, MouseEvent.BUTTON1, clickPoint.x, clickPoint.y, 2, 0);

	JWindow matchingWindow = textField.getActiveMatchingWindow();
	assertNull("The selection window is still showing after cancelling editing.",
		matchingWindow);
	assertEquals("The text of the selected item was not placed in the selection field.",
		selected, textField.getText());
}
 
Example #12
Source File: CoolPopupFactory.java    From Swing9patch with Apache License 2.0 6 votes vote down vote up
/**
 * Frees any resources the <code>Popup</code> may be holding onto.
 */
protected void dispose()
{
	Component component = getComponent();
	Window window = SwingUtilities.getWindowAncestor(component);

	if (component instanceof JWindow)
	{
		((Window) component).dispose();
		component = null;
	}
	// If our parent is a DefaultFrame, we need to dispose it, too.
	if (window instanceof DefaultFrame)
	{
		window.dispose();
	}
}
 
Example #13
Source File: DropDownTextFieldTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetText() {

	setText("d");

	JWindow matchingWindow = textField.getActiveMatchingWindow();

	// make sure our set text call did not trigger the window to be created
	assertNull(
		"The completion window has been created before any completion work " + "has began.",
		matchingWindow);

	clearText();
	typeText("d", true);

	// one more time
	clearText();
	setText("c");

	// make sure our set text call did not trigger the window to be created
	matchingWindow = textField.getActiveMatchingWindow();
	assertNull("The completion window has been created before any completion work has started",
		matchingWindow);
}
 
Example #14
Source File: WebAnno.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception
{
    Optional<JWindow> splash = LoadingSplashScreen
            .setupScreen(WebAnno.class.getResource("splash.png"));
    
    SpringApplicationBuilder builder = new SpringApplicationBuilder();
    // Add the main application as the root Spring context
    builder.sources(WebAnno.class).web(SERVLET);
    
    // Signal that we may need the shutdown dialog
    builder.properties("running.from.commandline=true");
    init(builder);
    builder.listeners(event -> {
        if (event instanceof ApplicationReadyEvent
                || event instanceof ShutdownDialogAvailableEvent) {
            splash.ifPresent(it -> it.dispose());
        }
    });
    builder.run(args);
}
 
Example #15
Source File: DropDownTextFieldTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testDropdownLocationOnParentMove() {

	// insert some text and make sure the window is created
	typeText("d", true);

	JWindow matchingWindow = textField.getActiveMatchingWindow();
	Point location = runSwing(() -> matchingWindow.getLocationOnScreen());
	Point frameLocation = parentFrame.getLocationOnScreen();
	Point p = new Point(frameLocation.x + 100, frameLocation.y + 100);
	runSwing(() -> parentFrame.setLocation(p));
	waitForSwing();

	JWindow currentMatchingWindow = textField.getActiveMatchingWindow();
	Point newLocation = runSwing(() -> currentMatchingWindow.getLocationOnScreen());
	assertNotEquals("The completion window's location did not update when its parent window " +
		"was moved.", location, newLocation);
}
 
Example #16
Source File: DropDownTextFieldTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testShowDropDownOnTextEntry() {

	JWindow matchingWindow = textField.getActiveMatchingWindow();

	// the window needs to be null initially because it must be properly parented when it is
	// created
	assertNull(
		"The completion window has been created before any completion work " + "has began.",
		matchingWindow);

	// insert some text and make sure the window is created
	typeText("d", true);

	// get the contents of the window and make sure that they are updated
	JList<String> jList = textField.getJList();
	int size = jList.getModel().getSize();

	// this will produce 'd2'
	typeText("2", true);

	assertNotEquals(
		"The number of matching items in the list did not change after typing more " + "text.",
		size, jList.getModel().getSize());
}
 
Example #17
Source File: GrabOnUnfocusableToplevel.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example #18
Source File: TranslucentPopup.java    From littleluck with Apache License 2.0 5 votes vote down vote up
TranslucentPopup(Component owner, Component contents, int ownerX, int ownerY) 
{ 
    this.popupWindow = new JWindow();
    popupWindow.setBackground(UIManager.getColor(LuckGlobalBundle.TRANSLUCENT_COLOR));
    popupWindow.setLocation(ownerX, ownerY); 
    popupWindow.getContentPane().add(contents, BorderLayout.CENTER); 
    contents.invalidate(); 
}
 
Example #19
Source File: LoadingSplashScreen.java    From webanno with Apache License 2.0 5 votes vote down vote up
public static Optional<JWindow> setupScreen(URL aImage)
{
    if (GraphicsEnvironment.isHeadless()) {
        return Optional.empty();
    }
    
    SplashWindow window = new SplashWindow(aImage);
    window.setVisible(true);
    
    return Optional.of(window);
}
 
Example #20
Source File: GrabOnUnfocusableToplevel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example #21
Source File: JLockWindow.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public JLockWindow(final Window parent) {
	this.parent = parent;
	jWindow = new JWindow(parent);

	jProgress = new JProgressBar(0, 100);

	JPanel jPanel = new JPanel();
	jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
	GroupLayout layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);
	jWindow.add(jPanel);

	jLabel = new JLabel();


	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.CENTER)
			.addComponent(jLabel)
			.addComponent(jProgress)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jLabel)
			.addComponent(jProgress)
	);
}
 
Example #22
Source File: CoolPopupFactory.java    From Swing9patch with Apache License 2.0 5 votes vote down vote up
/**
 * Hides and disposes of the <code>Popup</code>. Once a
 * <code>Popup</code> has been disposed you should no longer invoke
 * methods on it. A <code>dispose</code>d <code>Popup</code> may be
 * reclaimed and later used based on the <code>PopupFactory</code>. As
 * such, if you invoke methods on a <code>disposed</code>
 * <code>Popup</code>, indeterminate behavior will result.
 */
public void hide()
{
	Component component = getComponent();

	if (component instanceof JWindow)
	{
		component.hide();
		((JWindow) component).getContentPane().removeAll();
	}
	dispose();
}
 
Example #23
Source File: LuckPopupFactory.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
public void componentShown(ComponentEvent e)
{
    Object obj = e.getSource();
    
    if(obj instanceof JWindow)
    {
        JWindow window = (JWindow) obj;
        
        window.repaint();
    }
}
 
Example #24
Source File: GrabOnUnfocusableToplevel.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example #25
Source File: GrabOnUnfocusableToplevel.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example #26
Source File: GrabOnUnfocusableToplevel.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
Example #27
Source File: GlassPane.java    From 07kit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new {@link GlassPane}
 * @param window The glass pane is for this window
 * @param style Style of the notification
 * @param cornerRadius The corner radius of the window
 */
public GlassPane(JWindow window, INotificationStyle style, int cornerRadius) {
	super.setOpaque(false);
	fWindow = window;
	fStyle  = style;
	fCornerRadius = cornerRadius;
	
	fWindow.setGlassPane(this);
}
 
Example #28
Source File: AccessibilityChooser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final boolean checkComponent(Component comp) {
    if (comp instanceof JComponent) {
        return checkContext(comp.getAccessibleContext());
    } else if (comp instanceof JDialog) {
        return checkContext(comp.getAccessibleContext());
    } else if (comp instanceof JFrame) {
        return checkContext(comp.getAccessibleContext());
    } else if (comp instanceof JWindow) {
        return checkContext(comp.getAccessibleContext());
    } else {
        return false;
    }
}
 
Example #29
Source File: AbstractSliderTool.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
private void initializeSlider(TopicMapGraphPanel gp) {
    int minValue = getMinValue(gp);
    int maxValue = getMaxValue(gp);
    int defaultValue = getDefaultValue(gp);
    
    if(defaultValue < minValue) defaultValue = minValue;
    if(defaultValue > maxValue) defaultValue = maxValue;

    slider = new SimpleSlider(SimpleSlider.HORIZONTAL, minValue, maxValue, defaultValue);
    sliderLabel = new SimpleLabel();
    sliderPopup = new JWindow();

    slider.setPreferredSize(new Dimension(120, 24));
    slider.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    
    sliderLabel.setFont(UIConstants.smallButtonLabelFont);
    sliderLabel.setPreferredSize(new Dimension(30, 24));
    sliderLabel.setHorizontalAlignment(SimpleLabel.CENTER);
    
    JPanel panel = new JPanel();
    panel.setBorder(new LineBorder(UIConstants.defaultBorderShadow));
    panel.setLayout(new BorderLayout(2,2));
    panel.add(slider, BorderLayout.CENTER);
    panel.add(sliderLabel, BorderLayout.EAST);

    sliderPopup.setLayout(new BorderLayout(2,2));
    sliderPopup.add(panel, BorderLayout.CENTER);
    sliderPopup.setSize(150, 24);

    // sliderPopup.addMouseListener(this);
    sliderPopup.setAlwaysOnTop(true);
    
    slider.addChangeListener(this);
    slider.addMouseListener(this);
}
 
Example #30
Source File: GrabOnUnfocusableToplevel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}