类javax.swing.JRootPane源码实例Demo

下面列出了怎么用javax.swing.JRootPane的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: FlatLaf   文件: FlatTitlePane.java
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();
	}
}
 
源代码2 项目: littleluck   文件: LuckMetalRootPaneUI.java
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;
}
 
源代码3 项目: Course_Generator   文件: frmReleaseNote.java
/**
 * 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;
}
 
源代码4 项目: beautyeye   文件: BERootPaneUI.java
/**
 * 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;
}
 
源代码5 项目: visualvm   文件: WindowBuilders.java
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;
}
 
源代码6 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * 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);
        }
    }
}
 
源代码7 项目: netbeans   文件: ResizeGestureRecognizer.java
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;
}
 
源代码8 项目: netbeans   文件: NotificationLineSupportTest.java
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;
}
 
源代码9 项目: Swing9patch   文件: FloatableDialog.java
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);
	}
 
源代码10 项目: netbeans   文件: WindowBuilders.java
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;
}
 
源代码11 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * 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;
}
 
源代码12 项目: littleluck   文件: LuckRootPaneLayout.java
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);
}
 
源代码13 项目: rapidminer-studio   文件: RoundedRectanglePopup.java
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;
}
 
源代码14 项目: beautyeye   文件: BERootPaneUI.java
/**
 * 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;
}
 
源代码15 项目: ChatGameFontificator   文件: ChatWindow.java
/**
 * 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);
}
 
源代码16 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * 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();
    }
}
 
源代码17 项目: blog-codes   文件: EditorAboutFrame.java
/**
 * Overrides {@link JDialog#createRootPane()} to return a root pane that
 * hides the window when the user presses the ESCAPE key.O
 */
protected JRootPane createRootPane()
{
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener()
	{
		public void actionPerformed(ActionEvent actionEvent)
		{
			setVisible(false);
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	return rootPane;
}
 
源代码18 项目: openjdk-jdk9   文件: JDialogOperator.java
/**
 * Maps {@code JDialog.getRootPane()} through queue
 */
public JRootPane getRootPane() {
    return (runMapping(new MapAction<JRootPane>("getRootPane") {
        @Override
        public JRootPane map() {
            return ((JDialog) getSource()).getRootPane();
        }
    }));
}
 
源代码19 项目: FlatLaf   文件: JBRCustomDecorations.java
static void install( JRootPane rootPane ) {
	if( !isSupported() )
		return;

	// check whether root pane already has a parent, which is the case when switching LaF
	if( rootPane.getParent() != null )
		return;

	// Use hierarchy listener to wait until the root pane is added to a window.
	// Enabling JBR decorations must be done very early, probably before
	// window becomes displayable (window.isDisplayable()). Tried also using
	// "ancestor" property change event on root pane, but this is invoked too late.
	HierarchyListener addListener = new HierarchyListener() {
		@Override
		public void hierarchyChanged( HierarchyEvent e ) {
			if( e.getChanged() != rootPane || (e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) == 0 )
				return;

			Container parent = e.getChangedParent();
			if( parent instanceof Window )
				install( (Window) parent );

			// use invokeLater to remove listener to avoid that listener
			// is removed while listener queue is processed
			EventQueue.invokeLater( () -> {
				rootPane.removeHierarchyListener( this );
			} );
		}
	};
	rootPane.addHierarchyListener( addListener );
}
 
源代码20 项目: gcs   文件: Search.java
private void removeFloater() {
    if (mFloater != null) {
        JRootPane rootPane = getRootPane();
        Container parent   = mFloater.getParent();
        Rectangle bounds   = mFloater.getBounds();
        UIUtilities.convertRectangle(bounds, parent, rootPane);
        if (parent != null) {
            parent.remove(mFloater);
        }
        mFloater = null;
        if (rootPane != null) {
            rootPane.repaint(bounds);
        }
    }
}
 
源代码21 项目: FlatLaf   文件: FlatRootPaneUI.java
@Override
public void installUI( JComponent c ) {
	super.installUI( c );

	rootPane = (JRootPane) c;

	if( rootPane.getWindowDecorationStyle() != JRootPane.NONE )
		installClientDecorations();

	if( canUseJBRCustomDecorations )
		JBRCustomDecorations.install( rootPane );
}
 
源代码22 项目: beautyeye   文件: BERootPaneUI.java
/**
 * Uninstalls the previously installed <code>LayoutManager</code>.
 *
 * @param root the root
 */
private void uninstallLayout(JRootPane root) 
{
	if (savedOldLayout != null) 
	{
		root.setLayout(savedOldLayout);
		savedOldLayout = null;
	}
}
 
源代码23 项目: javamelody   文件: ShadowPopupFactory.java
/**
 * @return the top level layered pane which contains the owner.
 */
private Container getLayeredPane() {
	// The code below is copied from PopupFactory#LightWeightPopup#show()
	Container parent = null;
	if (owner != null) {
		parent = owner instanceof Container ? (Container) owner : owner.getParent();
	}
	// Try to find a JLayeredPane and Window to add
	for (Container p = parent; p != null; p = p.getParent()) {
		if (p instanceof JRootPane) {
			if (p.getParent() instanceof JInternalFrame) {
				continue;
			}
			parent = ((JRootPane) p).getLayeredPane();
			// Continue, so that if there is a higher JRootPane, we'll
			// pick it up.
		} else if (p instanceof Window) {
			if (parent == null) {
				parent = p;
			}
			break;
		} else if (p instanceof JApplet) {
			// Painting code stops at Applets, we don't want
			// to add to a Component above an Applet otherwise
			// you'll never see it painted.
			break;
		}
	}
	return parent;
}
 
源代码24 项目: dragonwell8_jdk   文件: InputMethodJFrame.java
/**
 * 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);
}
 
源代码25 项目: hottub   文件: InputMethodJFrame.java
/**
 * 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);
}
 
源代码26 项目: bigtable-sql   文件: OkClosePanel.java
/**
	 * Make the OK button the default. This should be called
	 * <EM>after</EM> you add this panel to a dialog/frame, not
	 * before otherwise you will get an <TT>IllegalStateException</TT>
	 * exception.
	 *
	 * @param	IllegalStateException
	 * 			Thrown if <TT>null</TT> <TT>JRootPane</TT>. I.E. component
	 * 			hasn't been added to a frame, dialog etc.
	 */
	public synchronized void makeOKButtonDefault()
			throws IllegalStateException
	{
		JRootPane root = getRootPane();
		if (root == null)
		{
			throw new IllegalStateException("Null RootPane so cannot set default button");
		}
//		root.setDefaultButton(_okBtn);
	}
 
源代码27 项目: jpexs-decompiler   文件: View.java
public static void installEscapeCloseOperation(final JDialog dialog) {
    Action dispatchClosing = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent event) {
            dialog.dispatchEvent(new WindowEvent(
                    dialog, WindowEvent.WINDOW_CLOSING));
        }
    };
    JRootPane root = dialog.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
            escapeStroke, dispatchWindowClosingActionMapKey);
    root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing);
}
 
源代码28 项目: openjdk-8   文件: InputMethodJFrame.java
/**
 * 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);
}
 
源代码29 项目: SubTitleSearcher   文件: ExtractDialog.java
@Override
protected JRootPane createRootPane() {
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			escapeKeyProc();
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

	return rootPane;
}
 
源代码30 项目: SubTitleSearcher   文件: AboutDialog.java
@Override
protected JRootPane createRootPane() {
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			escapeKeyProc();
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

	return rootPane;
}
 
 类所在包
 同包方法