65 |
*/ |
*/ |
66 |
public class SwingUtilities implements SwingConstants |
public class SwingUtilities implements SwingConstants |
67 |
{ |
{ |
68 |
|
/** |
69 |
private static Frame ownerFrame; |
* This frame should be used as parent for JWindow or JDialog |
70 |
|
* that doesn't an owner |
71 |
|
*/ |
72 |
|
private static OwnerFrame ownerFrame; |
73 |
|
|
74 |
/** |
/** |
75 |
* Calculates the portion of the base rectangle which is inside the |
* Calculates the portion of the base rectangle which is inside the |
200 |
* |
* |
201 |
* @see #getAncestorOfClass |
* @see #getAncestorOfClass |
202 |
* @see #windowForComponent |
* @see #windowForComponent |
|
* @see |
|
|
* |
|
203 |
*/ |
*/ |
204 |
public static Container getAncestorOfClass(Class c, Component comp) |
public static Container getAncestorOfClass(Class c, Component comp) |
205 |
{ |
{ |
712 |
{ |
{ |
713 |
case TOP: |
case TOP: |
714 |
textR.y = 0; |
textR.y = 0; |
715 |
iconR.y = textR.height + textIconGap; |
iconR.y = (horizontalTextPosition == CENTER |
716 |
|
? textR.height + textIconGap : 0); |
717 |
break; |
break; |
718 |
case BOTTOM: |
case BOTTOM: |
719 |
iconR.y = 0; |
iconR.y = 0; |
720 |
textR.y = iconR.height + textIconGap; |
textR.y = (horizontalTextPosition == CENTER |
721 |
|
? iconR.height + textIconGap |
722 |
|
: iconR.height - textR.height); |
723 |
break; |
break; |
724 |
case CENTER: |
case CENTER: |
725 |
int centerLine = Math.max(textR.height, iconR.height) / 2; |
int centerLine = Math.max(textR.height, iconR.height) / 2; |
842 |
} |
} |
843 |
|
|
844 |
/** |
/** |
845 |
* This method returns the common Frame owner used in JDialogs |
* This method returns the common Frame owner used in JDialogs or |
846 |
* when no owner is provided. |
* JWindow when no owner is provided. |
847 |
* |
* |
848 |
* @return The common Frame |
* @return The common Frame |
849 |
*/ |
*/ |
850 |
static Frame getOwnerFrame() |
static Frame getOwnerFrame() |
851 |
{ |
{ |
852 |
if (ownerFrame == null) |
if (ownerFrame == null) |
853 |
ownerFrame = new Frame(); |
ownerFrame = new OwnerFrame(); |
854 |
return ownerFrame; |
return ownerFrame; |
855 |
} |
} |
856 |
|
|
892 |
return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK) |
return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK) |
893 |
== InputEvent.BUTTON3_DOWN_MASK); |
== InputEvent.BUTTON3_DOWN_MASK); |
894 |
} |
} |
895 |
|
|
896 |
|
/** |
897 |
|
* This frame should be used when constructing a Window/JDialog without |
898 |
|
* a parent. In this case, we are forced to use this frame as a window's |
899 |
|
* parent, because we simply cannot pass null instead of parent to Window |
900 |
|
* constructor, since doing it will result in NullPointerException. |
901 |
|
*/ |
902 |
|
private static class OwnerFrame extends Frame |
903 |
|
{ |
904 |
|
public void setVisible(boolean b) |
905 |
|
{ |
906 |
|
// Do nothing here. |
907 |
|
} |
908 |
|
|
909 |
|
public boolean isShowing() |
910 |
|
{ |
911 |
|
return true; |
912 |
|
} |
913 |
|
} |
914 |
} |
} |