Java Code Examples for javax.swing.RootPaneContainer

The following examples show how to use javax.swing.RootPaneContainer. These examples are extracted from open source projects. 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 Project: FlatLaf   Source File: FlatInspector.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Installs a key listener into the application that allows enabling and disabling
 * the UI inspector with the given keystroke (e.g. "ctrl shift alt X").
 */
public static void install( String activationKeys ) {
	KeyStroke keyStroke = KeyStroke.getKeyStroke( activationKeys );
	Toolkit.getDefaultToolkit().addAWTEventListener( e -> {
		if( e.getID() == KeyEvent.KEY_RELEASED &&
			((KeyEvent)e).getKeyCode() == keyStroke.getKeyCode() &&
			(((KeyEvent)e).getModifiersEx() & KEY_MODIFIERS_MASK) == (keyStroke.getModifiers() & KEY_MODIFIERS_MASK)  )
		{
			Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
			if( activeWindow instanceof RootPaneContainer ) {
				JRootPane rootPane = ((RootPaneContainer)activeWindow).getRootPane();
				FlatInspector inspector = (FlatInspector) rootPane.getClientProperty( FlatInspector.class );
				if( inspector == null ) {
					inspector = new FlatInspector( rootPane );
					rootPane.putClientProperty( FlatInspector.class, inspector );
					inspector.setEnabled( true );
				} else {
					inspector.uninstall();
					rootPane.putClientProperty( FlatInspector.class, null );
				}
			}
		}
	}, AWTEvent.KEY_EVENT_MASK );
}
 
Example 2
Source Project: pumpernickel   Source File: CustomizedToolbar.java    License: MIT License 6 votes vote down vote up
/**
 * Are we painting against a dark background? This checks the JVM version,
 * the os, and whether the window's ultimate parent uses Apple's
 * brush-metal-look.
 */
protected static boolean isDarkBackground(Window w) {
	if (!isMac)
		return false;

	while (w != null) {
		if (w instanceof RootPaneContainer) {
			JRootPane rootPane = ((RootPaneContainer) w).getRootPane();
			Object obj = rootPane
					.getClientProperty("apple.awt.brushMetalLook");
			if (obj == null)
				obj = Boolean.FALSE;
			if (obj.toString().equals("true")) {
				return true;
			}
		}
		w = w.getOwner();
	}
	return false;
}
 
Example 3
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c;

    while (parent.getParent() != null) {

        if (parent instanceof RootPaneContainer) {
            break;
        }

        parent = parent.getParent();
    }

    if (parent instanceof JFrame) {
        return (((JFrame) parent).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
    } else if (parent instanceof JInternalFrame) {
        return ((JInternalFrame) parent).isMaximum();
    }

    return false;
}
 
Example 4
Source Project: CodenameOne   Source File: BlockingAction.java    License: GNU General Public License v2.0 6 votes vote down vote up
public final void run() {
    try {
        exectute();
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                afterComplete();
            }
        });
    } catch(Exception err) {
        err.printStackTrace();
    } finally {
        t.stop();
        RootPaneContainer r = (RootPaneContainer)ResourceEditorApp.getApplication().getMainFrame();
        r.setGlassPane(glassPane);
    }
}
 
Example 5
Source Project: netbeans   Source File: ZOrderManager.java    License: Apache License 2.0 6 votes vote down vote up
/** Stops to track given window (RootPaneContainer).
 */
public boolean detachWindow (RootPaneContainer rpc) {
    logger.entering(getClass().getName(), "detachWindow");

    if (!(rpc instanceof Window)) {
        throw new IllegalArgumentException("Argument must be subclas of java.awt.Window: " + rpc);   //NOI18N
    }

    WeakReference<RootPaneContainer> ww = getWeak(rpc);
    if (ww == null) {
        return false;
    }

    ((Window)rpc).removeWindowListener(this);
    return zOrder.remove(ww);
}
 
Example 6
Source Project: bboxdb   Source File: BBoxDBGui.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get the glass pane of the main panel
 * @return
 */
public Component getGlassPane() {
	
	if(mainPanel == null) {
		return null;
	}
	
	final RootPaneContainer root = 
			(RootPaneContainer) mainPanel.getTopLevelAncestor();
	   
	if(root == null) {
		return null;
	}
	
	return root.getGlassPane();
}
 
Example 7
Source Project: jdk8u_jdk   Source File: FullScreenHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 8
Source Project: spring-analysis-note   Source File: ProxyFactoryTests.java    License: MIT License 5 votes vote down vote up
@Test
@Ignore("Not implemented yet, see https://jira.springframework.org/browse/SPR-5708")
public void testExclusionOfNonPublicInterfaces() {
	JFrame frame = new JFrame();
	ProxyFactory proxyFactory = new ProxyFactory(frame);
	Object proxy = proxyFactory.getProxy();
	assertTrue(proxy instanceof RootPaneContainer);
	assertTrue(proxy instanceof Accessible);
}
 
Example 9
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 10
Source Project: jdk8u_jdk   Source File: JDialog741.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void start() {

        System.setProperty("jbre.popupwindow.settype", "true");

        jFrame = new JFrame("Wrong popup z-order");
        jFrame.setSize(200, 200);
        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        JPanel jPanel = new JPanel();
        jPanel.setPreferredSize(new Dimension(200, 200));

        Popup popup = PopupFactory.getSharedInstance().getPopup(jFrame, jPanel, 100, 100);
        windowAncestor = SwingUtilities.getWindowAncestor(jPanel);
        ((RootPaneContainer) windowAncestor).getRootPane().putClientProperty("SIMPLE_WINDOW", true);
        windowAncestor.setFocusable(true);
        windowAncestor.setFocusableWindowState(true);
        windowAncestor.setAutoRequestFocus(true);

        jFrame.setVisible(true);
        popup.show();


        modalBlocker = new JDialog(windowAncestor, "Modal Blocker");
        modalBlocker.setModal(true);
        modalBlocker.setSize(new Dimension(200, 200));
        modalBlocker.setLocation(200, 200);
        modalBlocker.addWindowListener(new JDialog741Listener());
        modalBlocker.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        modalBlocker.setVisible(true);
    }
 
Example 11
Source Project: snap-desktop   Source File: Session.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static Container getRootPaneContainer(JComponent component) {
    Container parent = component;
    Container lastParent;
    do {
        if (parent instanceof RootPaneContainer) {
            return parent;
        }
        lastParent = parent;
        parent = lastParent.getParent();
    } while (parent != null);
    return lastParent;
}
 
Example 12
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 13
Source Project: java-technology-stack   Source File: ProxyFactoryTests.java    License: MIT License 5 votes vote down vote up
@Test
@Ignore("Not implemented yet, see http://jira.springframework.org/browse/SPR-5708")
public void testExclusionOfNonPublicInterfaces() {
	JFrame frame = new JFrame();
	ProxyFactory proxyFactory = new ProxyFactory(frame);
	Object proxy = proxyFactory.getProxy();
	assertTrue(proxy instanceof RootPaneContainer);
	assertTrue(proxy instanceof Accessible);
}
 
Example 14
Source Project: jdk8u60   Source File: FullScreenHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 15
Source Project: jdk8u60   Source File: FullScreenHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void handleFullScreenEventFromNative(final Window window, final int type) {
    if (!(window instanceof RootPaneContainer)) return; // handles null

    SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
        public void run() {
            final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window);
            if (handler != null) handler.notifyListener(new FullScreenEvent(window), type);
        }
    });
}
 
Example 16
public static void startWaitCursor(JComponent component)
{
	RootPaneContainer root = ((RootPaneContainer) component.getTopLevelAncestor());
	root.getGlassPane().setCursor(WAIT_CURSOR);
	root.getGlassPane().addMouseListener(CLICK_CONSUMER);
	root.getGlassPane().setVisible(true);
	root.getRootPane().validate();
}
 
Example 17
Source Project: openjdk-8   Source File: FullScreenHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 18
Source Project: netbeans   Source File: ZOrderManager.java    License: Apache License 2.0 5 votes vote down vote up
public void clear () {
    RootPaneContainer rpc;
    for (WeakReference<RootPaneContainer> elem : zOrder) {
        rpc = elem.get();
        if (rpc != null) {
            ((Window)rpc).removeWindowListener(this);
        }
    }
    zOrder.clear();
}
 
Example 19
Source Project: spring4-understanding   Source File: ProxyFactoryTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Ignore("Not implemented yet, see http://jira.springframework.org/browse/SPR-5708")
public void testExclusionOfNonPublicInterfaces() {
	JFrame frame = new JFrame();
	ProxyFactory proxyFactory = new ProxyFactory(frame);
	Object proxy = proxyFactory.getProxy();
	assertTrue(proxy instanceof RootPaneContainer);
	assertTrue(proxy instanceof Accessible);
}
 
Example 20
Source Project: netbeans   Source File: ZOrderManager.java    License: Apache License 2.0 5 votes vote down vote up
private WeakReference<RootPaneContainer> getWeak (RootPaneContainer rpc) {
    for (WeakReference<RootPaneContainer> elem : zOrder) {
        if (elem.get() == rpc) {
            return elem;
        }
    }
    return null;
}
 
Example 21
Source Project: netbeans   Source File: ZOrderManager.java    License: Apache License 2.0 5 votes vote down vote up
private WeakReference<RootPaneContainer> getExcludedWeak (RootPaneContainer rpc) {
    for (WeakReference<RootPaneContainer> elem : excludeSet) {
        if (elem.get() == rpc) {
            return elem;
        }
    }
    return null;
}
 
Example 22
Source Project: jdk8u_jdk   Source File: JDialog705.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        SwingUtilities.invokeAndWait(() -> {
            jFrame = new JFrame("Wrong popup z-order");
            jFrame.setSize(200, 200);

            JPanel jPanel = new JPanel();
            jPanel.setPreferredSize(new Dimension(200, 200));
            jPanel.setBackground(Color.BLACK);

            Popup popup = PopupFactory.getSharedInstance().getPopup(jFrame, jPanel, 100, 100);
            windowAncestor = SwingUtilities.getWindowAncestor(jPanel);
            ((RootPaneContainer) windowAncestor).getRootPane().putClientProperty("SIMPLE_WINDOW", true);
            windowAncestor.setFocusable(true);
            windowAncestor.setFocusableWindowState(true);
            windowAncestor.setAutoRequestFocus(true);

            jFrame.setVisible(true);
            popup.show();


            modalBlocker = new JDialog(windowAncestor, "Modal Blocker");
            modalBlocker.setModal(true);
            modalBlocker.setSize(new Dimension(200, 200));
            modalBlocker.setLocation(200, 200);
            modalBlocker.addWindowListener(new DialogListener());

            modalBlocker.setVisible(true);
        });
    }
 
Example 23
Source Project: drmips   Source File: Util.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Configures the given window to be closed when the Escape button is pressed.
 * @param <W> A window (JFrame, JDialog, etc.).
 * @param window Window to configure.
 */
public static <W extends Window & RootPaneContainer> void enableCloseWindowWithEscape(final W window) {
	Action closeAction = new AbstractAction() {
		@Override
		public void actionPerformed(ActionEvent e) {
			window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
		}
	};
	
	window.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
	window.getRootPane().getActionMap().put("close", closeAction);
}
 
Example 24
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 25
public static void stopWaitCursor(JComponent component)
{
	RootPaneContainer root = ((RootPaneContainer) component.getTopLevelAncestor());
	root.getGlassPane().setCursor(DEFAULT_CURSOR);
	root.getGlassPane().removeMouseListener(CLICK_CONSUMER);
	root.getGlassPane().setVisible(false);
	root.getRootPane().validate();
}
 
Example 26
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 27
public static void stopWaitCursor(JComponent component)
{
	RootPaneContainer root = ((RootPaneContainer) component.getTopLevelAncestor());
	root.getGlassPane().setCursor(DEFAULT_CURSOR);
	root.getGlassPane().removeMouseListener(CLICK_CONSUMER);
	root.getGlassPane().setVisible(false);
	root.getRootPane().validate();
}
 
Example 28
Source Project: jdk8u-jdk   Source File: FullScreenHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
 
Example 29
Source Project: jdk8u-jdk   Source File: FullScreenHandler.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void handleFullScreenEventFromNative(final Window window, final int type) {
    if (!(window instanceof RootPaneContainer)) return; // handles null

    SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
        public void run() {
            final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window);
            if (handler != null) handler.notifyListener(new FullScreenEvent(window), type);
        }
    });
}
 
Example 30
Source Project: seaglass   Source File: SeaGlassTitlePane.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new SeaGlassTitlePane object.
 *
 * @param rootPane the JRootPane containing the title pane.
 * @param ui       the UI delegate for the root pane.
 */
public SeaGlassTitlePane(JRootPane rootPane, SeaGlassRootPaneUI ui) {
    this.rootPane   = rootPane;
    this.rootPaneUI = ui;
    rootParent      = (RootPaneContainer) rootPane.getParent();
    installTitlePane();
}