public final class GuiUtil extends Object
The GNU General Public License for details.
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
log
The log stream
|
Modifier | Constructor and Description |
---|---|
private |
GuiUtil()
Prevent instantiation
|
Modifier and Type | Method and Description |
---|---|
static void |
applyDefaultOrientation(Component comp)
Recursively apply default component orientation to the component and all
it contains.
|
static void |
applyOrientation(Component comp,
boolean ltr)
Recursively apply component orientation to the component and all it
contains.
|
static void |
applyOrientation(Component comp,
ComponentOrientation orientation)
Recursively apply component orientation to the component and all it
contains.
|
static void |
centerOnScreen(Window win)
Move the specified window to the center of the screen.
|
static void |
defaultDesktopSize(Window win)
Set the size of the main window to a default size.
|
static void |
enforceMinimumSize(Component comp,
int minWidth,
int minHeight)
Set the size of a component
|
static JButton |
flatten(JButton button) |
static Dialog |
getDialog(Component com)
Find the parent Frame
|
static Frame |
getFrame(Component parent)
Find the parent Frame.
|
static ImageIcon |
getIcon(String name)
Returns the Icon associated with the name from the resources.
|
static Frame |
getRootFrame()
Find the best frame to which to root a dialog, generally the largest
visible frame of the application.
|
static String |
getText(Component comp)
Attempts to get the text from a generic Component.
|
static Window |
getWindow(Component com)
Find the parent window.
|
static void |
maximizeWindow(Window win)
Maximize the specified window.
|
static void |
refresh(Component c)
Cause a component to refresh its contents when it is changed by the
program and needs to be redrawn.
|
static void |
restrainedPack(Window win,
float maxx,
float maxy)
A more restricted version of pack() when the component is being pack()ed
for the first time.
|
static void |
restrainedRePack(Window win)
A more restricted version of pack() for component responding to live
component tweaks.
|
static int |
setSize(Window win,
Dimension requestedDim)
Set the size of the window, but no bigger than the screen.
|
static void |
setSize(Window win,
float percentOfScreen)
Set the window size relative to the current screen size.
|
public static ImageIcon getIcon(String name)
name
- Name of the icon file i.e., help16.gifpublic static Window getWindow(Component com)
com
- a component to find the frame of.public static Frame getRootFrame()
public static Frame getFrame(Component parent)
parent
- a component to find the frame of.public static Dialog getDialog(Component com)
com
- a component to find the frame of.public static void centerOnScreen(Window win)
win
- The window to be movedpublic static int setSize(Window win, Dimension requestedDim)
On platforms that allow docking of other windows, this routine does not take that into account for sizes that are near that of the screen. For example, on Windows XP, the user may have a task bar showing permanently on one side of the screen and another application's toolbar on another side of the screen. If the requested size of the window is less than the screen size in a particular dimension, it will not be able to adjust for it.
For that reason, either have the application significantly smaller than the screen size or maximize the window.
win
- the window to resizerequestedDim
- how wide and tall to make the window, if possiblepublic static void setSize(Window win, float percentOfScreen)
win
- The window to resizepercentOfScreen
- The amount of space that the window should take uppublic static void defaultDesktopSize(Window win)
win
- The window to resizepublic static void maximizeWindow(Window win)
win
- The window to be movedpublic static void refresh(Component c)
c
- the component to refreshpublic static void restrainedRePack(Window win)
win
- The window to be packedpublic static void restrainedPack(Window win, float maxx, float maxy)
win
- The window to be packedmaxx
- The maximum fraction (0.0 to 1.0) of the screen to be taken up
horizontallymaxy
- The maximum fraction (0.0 to 1.0) of the screen to be taken up
verticallyrestrainedRePack(Window)
public static void enforceMinimumSize(Component comp, int minWidth, int minHeight)
public static String getText(Component comp)
comp
- The object containing the needed text.public static void applyDefaultOrientation(Component comp)
comp
- the root of the tree to which orientation needs to be appliedpublic static void applyOrientation(Component comp, boolean ltr)
comp
- the root of the tree to which orientation needs to be appliedltr
- whether the orientation is left to right or not.public static void applyOrientation(Component comp, ComponentOrientation orientation)
comp
- the root of the tree to which orientation needs to be appliedorientation
- the orientation to be applied