diff options
Diffstat (limited to 'javax/swing/SwingUtilities.java')
-rw-r--r-- | javax/swing/SwingUtilities.java | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java index 7162edbd7..62b156161 100644 --- a/javax/swing/SwingUtilities.java +++ b/javax/swing/SwingUtilities.java @@ -65,8 +65,11 @@ import java.lang.reflect.InvocationTargetException; */ public class SwingUtilities implements SwingConstants { - - private static Frame ownerFrame; + /** + * This frame should be used as parent for JWindow or JDialog + * that doesn't an owner + */ + private static OwnerFrame ownerFrame; /** * Calculates the portion of the base rectangle which is inside the @@ -197,8 +200,6 @@ public class SwingUtilities implements SwingConstants * * @see #getAncestorOfClass * @see #windowForComponent - * @see - * */ public static Container getAncestorOfClass(Class c, Component comp) { @@ -711,11 +712,14 @@ public class SwingUtilities implements SwingConstants { case TOP: textR.y = 0; - iconR.y = textR.height + textIconGap; + iconR.y = (horizontalTextPosition == CENTER + ? textR.height + textIconGap : 0); break; case BOTTOM: iconR.y = 0; - textR.y = iconR.height + textIconGap; + textR.y = (horizontalTextPosition == CENTER + ? iconR.height + textIconGap + : iconR.height - textR.height); break; case CENTER: int centerLine = Math.max(textR.height, iconR.height) / 2; @@ -838,15 +842,15 @@ public class SwingUtilities implements SwingConstants } /** - * This method returns the common Frame owner used in JDialogs - * when no owner is provided. + * This method returns the common Frame owner used in JDialogs or + * JWindow when no owner is provided. * * @return The common Frame */ static Frame getOwnerFrame() { if (ownerFrame == null) - ownerFrame = new Frame(); + ownerFrame = new OwnerFrame(); return ownerFrame; } @@ -888,4 +892,23 @@ public class SwingUtilities implements SwingConstants return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK); } + + /** + * This frame should be used when constructing a Window/JDialog without + * a parent. In this case, we are forced to use this frame as a window's + * parent, because we simply cannot pass null instead of parent to Window + * constructor, since doing it will result in NullPointerException. + */ + private static class OwnerFrame extends Frame + { + public void setVisible(boolean b) + { + // Do nothing here. + } + + public boolean isShowing() + { + return true; + } + } } |