Fields Summary |
---|
private static final String[] | borderKeysKeys to lookup borders in defaults table. |
private static final int | CORNER_DRAG_WIDTHThe amount of space (in pixels) that the cursor is changed on. |
private static final int | BORDER_DRAG_THICKNESSRegion from edges that dragging is active from. |
private Window | windowWindow the JRootPane is in. |
private JComponent | titlePaneJComponent providing window decorations. This will be
null if not providing window decorations. |
private MouseInputListener | mouseInputListenerMouseInputListener that is added to the parent
Window the JRootPane is contained in. |
private LayoutManager | layoutManagerThe LayoutManager that is set on the
JRootPane . |
private LayoutManager | savedOldLayoutLayoutManager of the JRootPane before we
replaced it. |
private JRootPane | rootJRootPane providing the look and feel for. |
private Cursor | lastCursorCursor used to track the cursor set by the user.
This is initially Cursor.DEFAULT_CURSOR . |
private static final int[] | cursorMappingMaps from positions to cursor type. Refer to calculateCorner and
calculatePosition for details of this. |
Methods Summary |
---|
private java.awt.LayoutManager | createLayoutManager()Returns a LayoutManager that will be set on the
JRootPane .
return new MetalRootLayout();
|
private javax.swing.JComponent | createTitlePane(javax.swing.JRootPane root)Returns the JComponent to render the window decoration
style.
return new MetalTitlePane(root, this);
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)Creates a UI for a JRootPane .
return new MetalRootPaneUI();
|
private javax.swing.event.MouseInputListener | createWindowMouseInputListener(javax.swing.JRootPane root)Returns a MouseListener that will be added to the
Window containing the JRootPane .
return new MouseInputHandler();
|
private javax.swing.JRootPane | getRootPane()Returns the JRootPane we're providing the look and
feel for.
return root;
|
private javax.swing.JComponent | getTitlePane()Returns the JComponent rendering the title pane. If this
returns null, it implies there is no need to render window decorations.
return titlePane;
|
void | installBorder(javax.swing.JRootPane root)Installs the appropriate Border onto the
JRootPane .
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE) {
LookAndFeel.uninstallBorder(root);
}
else {
LookAndFeel.installBorder(root, borderKeys[style]);
}
|
private void | installClientDecorations(javax.swing.JRootPane root)Installs the necessary state onto the JRootPane to render client
decorations. This is ONLY invoked if the JRootPane
has a decoration style other than JRootPane.NONE .
installBorder(root);
JComponent titlePane = createTitlePane(root);
setTitlePane(root, titlePane);
installWindowListeners(root, root.getParent());
installLayout(root);
if (window != null) {
root.revalidate();
root.repaint();
}
|
private void | installLayout(javax.swing.JRootPane root)Installs the appropriate LayoutManager on the JRootPane
to render the window decorations.
if (layoutManager == null) {
layoutManager = createLayoutManager();
}
savedOldLayout = root.getLayout();
root.setLayout(layoutManager);
|
public void | installUI(javax.swing.JComponent c)Invokes supers implementation of installUI to install
the necessary state onto the passed in JRootPane
to render the metal look and feel implementation of
RootPaneUI . If
the windowDecorationStyle property of the
JRootPane is other than JRootPane.NONE ,
this will add a custom Component to render the widgets to
JRootPane , as well as installing a custom
Border and LayoutManager on the
JRootPane .
super.installUI(c);
root = (JRootPane)c;
int style = root.getWindowDecorationStyle();
if (style != JRootPane.NONE) {
installClientDecorations(root);
}
|
private void | installWindowListeners(javax.swing.JRootPane root, java.awt.Component parent)Installs the necessary Listeners on the parent Window ,
if there is one.
This takes the parent so that cleanup can be done from
removeNotify , at which point the parent hasn't been
reset yet.
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);
}
|
public void | propertyChange(java.beans.PropertyChangeEvent e)Invoked when a property changes. MetalRootPaneUI is
primarily interested in events originating from the
JRootPane it has been installed on identifying the
property windowDecorationStyle . If the
windowDecorationStyle has changed to a value other
than JRootPane.NONE , this will add a Component
to the JRootPane to render the window decorations, as well
as installing a Border on the JRootPane .
On the other hand, if the windowDecorationStyle has
changed to JRootPane.NONE , this will remove the
Component that has been added to the JRootPane
as well resetting the Border to what it was before
installUI was invoked.
super.propertyChange(e);
String propertyName = e.getPropertyName();
if(propertyName == null) {
return;
}
if(propertyName.equals("windowDecorationStyle")) {
JRootPane root = (JRootPane) e.getSource();
int style = root.getWindowDecorationStyle();
// This is potentially more than needs to be done,
// but it rarely happens and makes the install/uninstall process
// simpler. MetalTitlePane also assumes it will be recreated if
// the decoration style changes.
uninstallClientDecorations(root);
if (style != JRootPane.NONE) {
installClientDecorations(root);
}
}
else if (propertyName.equals("ancestor")) {
uninstallWindowListeners(root);
if (((JRootPane)e.getSource()).getWindowDecorationStyle() !=
JRootPane.NONE) {
installWindowListeners(root, root.getParent());
}
}
return;
|
private void | setTitlePane(javax.swing.JRootPane root, javax.swing.JComponent titlePane)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.
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;
|
private void | uninstallBorder(javax.swing.JRootPane root)Removes any border that may have been installed.
LookAndFeel.uninstallBorder(root);
|
private void | uninstallClientDecorations(javax.swing.JRootPane root)Uninstalls any state that installClientDecorations has
installed.
NOTE: This may be called if you haven't installed client decorations
yet (ie before installClientDecorations has been invoked).
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;
|
private void | uninstallLayout(javax.swing.JRootPane root)Uninstalls the previously installed LayoutManager .
if (savedOldLayout != null) {
root.setLayout(savedOldLayout);
savedOldLayout = null;
}
|
public void | uninstallUI(javax.swing.JComponent c)Invokes supers implementation to uninstall any of its state. This will
also reset the LayoutManager of the JRootPane .
If a Component has been added to the JRootPane
to render the window decoration style, this method will remove it.
Similarly, this will revert the Border and LayoutManager of the
JRootPane to what it was before installUI
was invoked.
super.uninstallUI(c);
uninstallClientDecorations(root);
layoutManager = null;
mouseInputListener = null;
root = null;
|
private void | uninstallWindowListeners(javax.swing.JRootPane root)Uninstalls the necessary Listeners on the Window the
Listeners were last installed on.
if (window != null) {
window.removeMouseListener(mouseInputListener);
window.removeMouseMotionListener(mouseInputListener);
}
|