diff options
author | Roman Kennke <roman@kennke.org> | 2006-03-13 20:51:58 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-03-13 20:51:58 +0000 |
commit | fba0f38be98affc45ad0c5f8c7129ebe65478f6c (patch) | |
tree | 67486108e4b624e52d3b3d75d2bb1ee8568c1357 /javax/swing/SwingUtilities.java | |
parent | f81f375ae014b57461ce3bd7f41f9702a8ee6db7 (diff) | |
download | classpath-fba0f38be98affc45ad0c5f8c7129ebe65478f6c.tar.gz |
2006-03-13 Roman Kennke <kennke@aicas.com>
* javax/swing/SwingUtilities.java
(updateComponentTreeUI): Rewritten to be more robust. Handling of
menus and non-Swing components is improved.
(updateComponentTreeUIImpl): New helper method.
(replaceUIActionMap): Added check for uiActionMap==parent to
avoid loop.
(replaceUIInputMap): Added check for uiInputMap==parent to
avoid loop.
Diffstat (limited to 'javax/swing/SwingUtilities.java')
-rw-r--r-- | javax/swing/SwingUtilities.java | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java index 6762ccd80..c5b80f613 100644 --- a/javax/swing/SwingUtilities.java +++ b/javax/swing/SwingUtilities.java @@ -600,20 +600,46 @@ public class SwingUtilities */ public static void updateComponentTreeUI(Component comp) { - if (comp == null) - return; - - if (comp instanceof Container) + updateComponentTreeUIImpl(comp); + if (comp instanceof JComponent) { - Component[] children = ((Container)comp).getComponents(); - for (int i = 0; i < children.length; ++i) - updateComponentTreeUI(children[i]); + JComponent jc = (JComponent) comp; + jc.revalidate(); } - - if (comp instanceof JComponent) - ((JComponent)comp).updateUI(); + else + { + comp.invalidate(); + comp.validate(); + } + comp.repaint(); } + /** + * Performs the actual work for {@link #updateComponentTreeUI(Component)}. + * This calls updateUI() on c if it is a JComponent, and then walks down + * the component tree and calls this method on each child component. + * + * @param c the component to update the UI + */ + private static void updateComponentTreeUIImpl(Component c) + { + if (c instanceof JComponent) + { + JComponent jc = (JComponent) c; + jc.updateUI(); + } + + Component[] components = null; + if (c instanceof JMenu) + components = ((JMenu) c).getMenuComponents(); + else if (c instanceof Container) + components = ((Container) c).getComponents(); + if (components != null) + { + for (int i = 0; i < components.length; ++i) + updateComponentTreeUIImpl(components[i]); + } + } /** * <p>Layout a "compound label" consisting of a text string and an icon @@ -1128,7 +1154,9 @@ public class SwingUtilities child = parent; parent = child.getParent(); } - child.setParent(uiActionMap); + // Sanity check to avoid loops. + if (child != uiActionMap) + child.setParent(uiActionMap); } } @@ -1170,7 +1198,9 @@ public class SwingUtilities child = parent; parent = parent.getParent(); } - child.setParent(uiInputMap); + // Sanity check to avoid loops. + if (child != uiInputMap) + child.setParent(uiInputMap); } } |