javax.swing.JRootPane Java Examples

The following examples show how to use javax.swing.JRootPane. 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: BERootPaneUI.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the window title pane -- the JComponent used to provide a plaf a
 * way to override the native operating system's window title pane with
 * one whose look and feel are controlled by the plaf.  The plaf creates
 * and sets this value; the default is null, implying a native operating
 * system window title pane.
 *
 * @param root the root
 * @param titlePane the title pane
 */
private void setTitlePane(JRootPane root, JComponent titlePane) 
{
	JLayeredPane layeredPane = root.getLayeredPane();
	JComponent oldTitlePane = getTitlePane();

	if (oldTitlePane != null)
	{
		oldTitlePane.setVisible(false);
		layeredPane.remove(oldTitlePane);
	}
	if (titlePane != null) 
	{
		layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
		titlePane.setVisible(true);
	}
	this.titlePane = titlePane;
}
 
Example #2
Source File: NotificationLineSupportTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static JLabel findNotificationLabel (Container container) {
    for (Component component : container.getComponents ()) {
        if (component.getClass ().getName ().indexOf (NOTIFICATION_LABEL_NAME) != -1) {
            return (JLabel) component;
        }
        if (component instanceof JRootPane) {
            JRootPane rp = (JRootPane) component;
            return findNotificationLabel (rp.getContentPane ());
        }
        if (component instanceof JPanel) {
            JPanel p = (JPanel) component;
            return findNotificationLabel (p);
        }
    }
    return null;
}
 
Example #3
Source File: FlatTitlePane.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
protected void frameStateChanged() {
	if( window == null || rootPane.getWindowDecorationStyle() != JRootPane.FRAME )
		return;

	if( window instanceof Frame ) {
		Frame frame = (Frame) window;
		boolean resizable = frame.isResizable();
		boolean maximized = ((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0);

		iconifyButton.setVisible( true );
		maximizeButton.setVisible( resizable && !maximized );
		restoreButton.setVisible( resizable && maximized );
	} else {
		// hide buttons because they are only supported in frames
		iconifyButton.setVisible( false );
		maximizeButton.setVisible( false );
		restoreButton.setVisible( false );

		revalidate();
		repaint();
	}
}
 
Example #4
Source File: WindowBuilders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected JInternalFrame createInstanceImpl() {
    JInternalFrame frame = new JInternalFrame(title, resizable, closable, maximizable, iconable) {
        protected JRootPane createRootPane() {
            return _rootPane == null ? null : _rootPane.createInstance();
        }
        public void addNotify() {
            try {
                // Doesn't seem to work correctly
                setClosed(_isClosed);
                setMaximum(_isMaximum);
                setIcon(_isIcon);
                setSelected(_isSelected);
            } catch (PropertyVetoException ex) {}
        }
    };
    return frame;
}
 
Example #5
Source File: FloatableDialog.java    From Swing9patch with Apache License 2.0 6 votes vote down vote up
protected void initGUI()
	{
		// set dialog full transparent
		setUndecorated(true);
		AWTUtilities.setWindowOpaque(this, false);
		this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);

		// init gui
		JPanel contentPane = new JPanel();
		contentPane.setLayout(new BorderLayout(0, 0));
		contentPane.setOpaque(false);
		setContentPane(contentPane);
				
		// others setup
		this.setFocusable(false);
		this.setFocusableWindowState(false);
//		this.setAlwaysOnTop(true);
		this.setVisible(false);
	}
 
Example #6
Source File: ResizeGestureRecognizer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void resetState() {
    state = STATE_NOOP;
    JRootPane pane = SwingUtilities.getRootPane(comp);
    glass.setVisible(false);
    if (pane != null && oldGlass != null) {
        // when clicking results in hidden slide window, pne can be null?
        // how to avoid?
        JComponent current = (JComponent) pane.getGlassPane();
        if (current instanceof GlassPane) {
            pane.setGlassPane(oldGlass);
        }
    }
    if( null != comp )
        comp.setCursor(null);
    oldGlass = null;
    startPoint = null;
}
 
Example #7
Source File: SeaGlassRootPaneUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Installs the necessary state onto the JRootPane to render client
 * decorations. This is ONLY invoked if the <code>JRootPane</code> has a
 * decoration style other than <code>JRootPane.NONE</code>.
 *
 * @param root the JRootPane.
 */
private void installClientDecorations(JRootPane root) {
    installBorder(root);
    if (root.getParent() instanceof JFrame || root.getParent() instanceof JDialog) {
        if (PlatformUtils.isMac()) {
            makeFrameBackgroundTransparent(root);
        } else {
            shapeWindow(root);
        }
    }

    JComponent titlePane = createTitlePane(root);

    setTitlePane(root, titlePane);
    installWindowListeners(root, root.getParent());
    installLayout(root);
    if (window != null) {
        root.revalidate();
        root.repaint();
    }
}
 
Example #8
Source File: SeaGlassRootPaneUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Installs the necessary Listeners on the parent <code>Window</code>, if
 * there is one.
 *
 * <p>This takes the parent so that cleanup can be done from <code>
 * removeNotify</code>, at which point the parent hasn't been reset yet.</p>
 *
 * @param root   the JRootPane.
 * @param parent The parent of the JRootPane
 */
private void installWindowListeners(JRootPane root, Component parent) {
    if (parent instanceof Window) {
        window = (Window) parent;
    } else {
        window = SwingUtilities.getWindowAncestor(parent);
    }

    if (window != null) {
        if (mouseInputListener == null) {
            mouseInputListener = createWindowMouseInputListener(root);
        }

        window.addMouseListener(mouseInputListener);
        window.addMouseMotionListener(mouseInputListener);
        if (windowListener == null) {
            windowListener = createFocusListener();
            window.addWindowListener(windowListener);
        }
    }
}
 
Example #9
Source File: LuckRootPaneLayout.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public Dimension maximumLayoutSize(Container parent)
{
    Insets insets = parent.getInsets();

    JRootPane root = (JRootPane) parent;

    Dimension cpd = null;

    if (root.getContentPane() != null)
    {
        cpd = root.getContentPane().getMaximumSize();
    }
    else
    {
        cpd = root.getSize();
    }

    return getDimension(insets, cpd.width, cpd.height);
}
 
Example #10
Source File: ChatWindow.java    From ChatGameFontificator with The Unlicense 6 votes vote down vote up
/**
 * Does the work required to make the parameter JDialog be hidden when pressing escape
 * 
 * @param popup
 */
public static void setupHideOnEscape(final JDialog popup)
{
    Action aa = new AbstractAction()
    {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event)
        {
            popup.setVisible(false);
        }
    };
    final String mapKey = "escapePressed";
    JRootPane root = popup.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, mapKey);
    root.getActionMap().put(mapKey, aa);
}
 
Example #11
Source File: LuckMetalRootPaneUI.java    From littleluck with Apache License 2.0 6 votes vote down vote up
protected void installTitlePane(JRootPane root, LuckTitlePanel titlePane, Window window)
{
    JLayeredPane layeredPane = root.getLayeredPane();

    JComponent oldTitlePane = getTitlePane();

    if (oldTitlePane != null)
    {
        oldTitlePane.setVisible(false);

        layeredPane.remove(oldTitlePane);
    }

    if (titlePane != null)
    {
    	titlePane.setOpaque(true);
    	
        layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);

        titlePane.setVisible(true);
    }

    this.titlePane = titlePane;
}
 
Example #12
Source File: frmReleaseNote.java    From Course_Generator with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Manage low level key strokes ESCAPE : Close the window
 *
 * @return
 */
protected JRootPane createRootPane() {
	JRootPane rootPane = new JRootPane();
	KeyStroke strokeEscape = KeyStroke.getKeyStroke("ESCAPE");

	@SuppressWarnings("serial")
	Action actionListener = new AbstractAction() {
		public void actionPerformed(ActionEvent actionEvent) {
			setVisible(false);
		}
	};

	InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	inputMap.put(strokeEscape, "ESCAPE");
	rootPane.getActionMap().put("ESCAPE", actionListener);

	return rootPane;
}
 
Example #13
Source File: BERootPaneUI.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
 * Uninstalls any state that <code>installClientDecorations</code> has
 * installed.
 * <p>
 * NOTE: This may be called if you haven't installed client decorations
 * yet (ie before <code>installClientDecorations</code> has been invoked).
 *
 * @param root the root
 */
private void uninstallClientDecorations(JRootPane root) 
{
	uninstallBorder(root);
	uninstallWindowListeners(root);
	setTitlePane(root, null);
	uninstallLayout(root);
	// We have to revalidate/repaint root if the style is JRootPane.NONE
	// only. When we needs to call revalidate/repaint with other styles
	// the installClientDecorations is always called after this method
	// imediatly and it will cause the revalidate/repaint at the proper
	// time.
	int style = root.getWindowDecorationStyle();
	if (style == JRootPane.NONE) 
	{
		root.repaint();
		root.revalidate();
	}
	// Reset the cursor, as we may have changed it to a resize cursor
	if (window != null) 
	{
		window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}
	window = null;
}
 
Example #14
Source File: WindowBuilders.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected JInternalFrame createInstanceImpl() {
    JInternalFrame frame = new JInternalFrame(title, resizable, closable, maximizable, iconable) {
        protected JRootPane createRootPane() {
            return _rootPane == null ? null : _rootPane.createInstance();
        }
        public void addNotify() {
            try {
                // Doesn't seem to work correctly
                setClosed(_isClosed);
                setMaximum(_isMaximum);
                setIcon(_isIcon);
                setSelected(_isSelected);
            } catch (PropertyVetoException ex) {}
        }
    };
    return frame;
}
 
Example #15
Source File: RoundedRectanglePopup.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
private Component getLayeredPane() {
	Container parent = null;
	if (this.owner != null) {
		parent = this.owner instanceof Container ? (Container) this.owner : this.owner.getParent();
	}
	for (Container p = parent; p != null; p = p.getParent()) {
		if (p instanceof JRootPane) {
			if (p.getParent() instanceof JInternalFrame) {
				continue;
			}
			parent = ((JRootPane) p).getLayeredPane();
		} else if (p instanceof Window) {
			if (parent == null) {
				parent = p;
			}
			break;
		} else if (p instanceof JApplet) {
			break;
		}
	}
	return parent;
}
 
Example #16
Source File: SeaGlassRootPaneUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the window title pane -- the JComponent used to provide a plaf a way
 * to override the native operating system's window title pane with one
 * whose look and feel are controlled by the plaf. The plaf creates and sets
 * this value; the default is null, implying a native operating system
 * window title pane.
 *
 * @param root      content the <code>JComponent</code> to use for the
 *                  window title pane.
 * @param titlePane the SeaGlassTitlePane.
 */
private void setTitlePane(JRootPane root, JComponent titlePane) {
    JLayeredPane layeredPane  = root.getLayeredPane();
    JComponent   oldTitlePane = getTitlePane();

    if (oldTitlePane != null) {
        oldTitlePane.setVisible(false);
        layeredPane.remove(oldTitlePane);
    }

    if (titlePane != null) {
        layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
        titlePane.setVisible(true);
    }

    this.titlePane = titlePane;
}
 
Example #17
Source File: POptionPane.java    From PolyGlot with MIT License 5 votes vote down vote up
private static int internalStyleFromMessageType(int messageType) {
    switch (messageType) {
        case ERROR_MESSAGE:
            return JRootPane.ERROR_DIALOG;
        case QUESTION_MESSAGE:
            return JRootPane.QUESTION_DIALOG;
        case WARNING_MESSAGE:
            return JRootPane.WARNING_DIALOG;
        case INFORMATION_MESSAGE:
            return JRootPane.INFORMATION_DIALOG;
        case PLAIN_MESSAGE:
        default:
            return JRootPane.PLAIN_DIALOG;
    }
}
 
Example #18
Source File: TimableEventQueue.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean isWaitCursorOnWindow(Window w) {
    if (w.getCursor().getType() == Cursor.WAIT_CURSOR) {
        return true;
    }
    if (w instanceof JFrame) {
        JRootPane root = ((JFrame)w).getRootPane();
        if (null != root) {
            Component glass = root.getGlassPane();
            if (null != glass && glass.getCursor().getType() == Cursor.WAIT_CURSOR) {
                return true;
            }
        }
    }
    return false;
}
 
Example #19
Source File: DropGlassPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Sets the original glass pane to the root pane of stored container.
 */
static void putBackOriginal() {
    if (oldPane == null) {
        throw new IllegalStateException("No original pane present");
    }
    final JRootPane rp = originalSource.getRootPane();
    if (rp == null) {
        if( null != SwingUtilities.getWindowAncestor( originalSource ) ) //#232187 - only complain when the originalSource is still in component hierarchy
            throw new IllegalStateException("originalSource " + originalSource + " has no root pane: " + rp); // NOI18N
    } else {
        rp.setGlassPane(oldPane);
        oldPane.setVisible(wasVisible);
    }
    oldPane = null;
}
 
Example #20
Source File: InputMethodJFrame.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Swing based input method window.
 */
public InputMethodJFrame(String title, InputContext context) {
    super(title);
    //InputMethodJFrame never has LookAndFeel decoration
    if(JFrame.isDefaultLookAndFeelDecorated())
    {
       this.setUndecorated(true);
       this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
    }
    if (context != null) {
        this.inputContext = context;
    }
    setFocusableWindowState(false);
}
 
Example #21
Source File: BaseTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = bt.getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
Example #22
Source File: FocusAfterBadEditTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testFocusReturn() throws Exception {
    if (!focusWorks) {
        return;
    }
    clickOn(tb, 1, 1);
    requestFocus(tb);
    typeKey(tb, KeyEvent.VK_B);
    typeKey(tb, KeyEvent.VK_E);
    typeKey(tb, KeyEvent.VK_SPACE);
    typeKey(tb, KeyEvent.VK_N);
    typeKey(tb, KeyEvent.VK_I);
    typeKey(tb, KeyEvent.VK_C);
    typeKey(tb, KeyEvent.VK_E);
    sleep();
    SLEEP_LENGTH=1000;
    Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    sleep();
    pressKey(c, KeyEvent.VK_ENTER);
    typeKey(c, KeyEvent.VK_ENTER);
    sleep();
    sleep();
    sleep();
    sleep();
    c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    assertNotNull(c);
    Container top = ((JComponent) c).getTopLevelAncestor();
    assertTrue("Focus should no longer be on the property sheet after an erroneous value was entered", top != jf);
    assertTrue("An error dialog should be showing after an exception was thrown in setAsText() but focus owner is " + c, jf != top);
    
    JRootPane jrp = ((JComponent) c).getRootPane();
    jrp.getDefaultButton().doClick();
    sleep();
    
    c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    assertTrue("After the error dialog is closed following a bad property edit, the table should return to edit mode on the previously edited property",
            c instanceof InplaceEditor);
    
}
 
Example #23
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Updates state dependant upon the Window's active state.
 *
 * @param isActive the new active
 */
private void setActive(boolean isActive)
{
	Boolean activeB = isActive ? Boolean.TRUE : Boolean.FALSE;
	closeButton.putClientProperty("paintActive", activeB);
	if (getWindowDecorationStyle() == JRootPane.FRAME)
	{
		iconifyButton.putClientProperty("paintActive", activeB);
		toggleButton.putClientProperty("paintActive", activeB);
	}
	// Repaint the whole thing as the Borders that are used have
	// different colors for active vs inactive
	getRootPane().repaint();
}
 
Example #24
Source File: EditablePropertyDisplayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void trySendEnterToDialog() {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
Example #25
Source File: ProgressPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void open(JComponent progressComponent) {
    holder.add(progressComponent, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ProgressPanel.class, "MSG_PleaseWait"),
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null,
            true);
    dialog = DialogDisplayer.getDefault().createDialog(dd);
    if (dialog instanceof JDialog) {
        JDialog jDialog = ((JDialog)dialog);
        jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        JRootPane rootPane = jDialog.getRootPane();
        rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
        rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
Example #26
Source File: PopupManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Install popup panel to current textComponent root pane */
private void installToRootPane(JComponent c) {
    JRootPane rp = textComponent.getRootPane();
    if (rp != null) {
        rp.getLayeredPane().add(c, JLayeredPane.POPUP_LAYER, 0);
    }
}
 
Example #27
Source File: LuckRootPaneUI.java    From littleluck with Apache License 2.0 5 votes vote down vote up
protected void installOther(JRootPane root)
{
    Window window = (Window) root.getParent();

    // 设置窗体为完全透明
    // set window translucent
    window.setBackground(UIManager.getColor(LuckGlobalBundle.TRANSLUCENT_COLOR));
}
 
Example #28
Source File: MainMenu.java    From COMP6237 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Construct the UI
 */
public MainMenu() {
	final List<LectureObject> lectures = getLectures();

	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
	tabs = new JTabbedPane();
	final List<JButton> runBtns = new ArrayList<JButton>();
	for (final LectureObject l : lectures) {
		final Component lp = createLecturePanel(l, runBtns);
		tabs.addTab(l.lecture.title(), lp);
	}

	tabs.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			final int idx = tabs.getSelectedIndex();
			final JRootPane root = MainMenu.this.getRootPane();

			if (root != null && idx >= 0)
				root.setDefaultButton(runBtns.get(idx));
		}
	});

	add(tabs);

	final JPanel info = new JPanel(new GridLayout(0, 1));
	info.setPreferredSize(new Dimension(800, 30));
	info.setSize(info.getPreferredSize());
	info.setMaximumSize(info.getPreferredSize());

	final JLabel link = Utils.linkify("http://comp6237.ecs.soton.ac.uk", "http://comp6237.ecs.soton.ac.uk",
			"Go to the course web site");
	link.setHorizontalAlignment(SwingConstants.CENTER);
	info.add(link);

	add(info);
}
 
Example #29
Source File: LuckWindowUtil.java    From littleluck with Apache License 2.0 5 votes vote down vote up
/**
 * 获取窗体根窗格
 *
 * @param window 窗体
 * @return 返回窗体根窗格
 */
public static JRootPane getRootPane(Window window)
{
    if(window instanceof JFrame)
    {
        return ((JFrame)window).getRootPane();
    }

    if(window instanceof JDialog)
    {
        return ((JDialog)window).getRootPane();
    }

    return null;
}
 
Example #30
Source File: SeaGlassRootPaneUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Update te control style.
 *
 * @param c the component.
 */
private void updateStyle(JComponent c) {
    SeaGlassContext context  = getContext(c, ENABLED);
    SynthStyle      oldStyle = style;

    style = SeaGlassLookAndFeel.updateStyle(context, this);
    if (style != oldStyle) {
        if (oldStyle != null) {
            uninstallKeyboardActions((JRootPane) c);
            installKeyboardActions((JRootPane) c);
        }
    }

    context.dispose();
}