Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.swing
Class GuiUtil

    java.lang.Object
      org.crosswire.common.swing.GuiUtil

    public final class GuiUtil

extends Object

Various GUI Utilities.

Author:
  Joe Walker
See Also:
  `The GNU General Public License for details.`

Field Summary
`private static org.slf4j.Logger` | `log` The log stream

Constructor Summary
`private` | `GuiUtil()` Prevent instantiation

Method Summary
`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 min_width, int min_height)` 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final org.slf4j.Logger log

  The log stream

Constructor Detail

### GuiUtil

    private GuiUtil()

  Prevent instantiation

Method Detail

### getIcon

    public static ImageIcon getIcon(String name)

  Returns the Icon associated with the name from the resources. The resource should be in the path.

  Parameters:
    `name` - Name of the icon file i.e., help16.gif
  Returns:
    the image or null if the icon is not found.

### getWindow

    public static Window getWindow(Component com)

  Find the parent window.

  Parameters:
    `com` - a component to find the frame of.
  Returns:
    The parent Window

### getRootFrame

    public static Frame getRootFrame()

  Find the best frame to which to root a dialog, generally the largest visible frame of the application.

  Returns:
    the best frame.

### getFrame

    public static Frame getFrame(Component parent)

  Find the parent Frame. This method can do more than simply walking up the tree to find a parent frame by looking for default frames from JOptionPane and by looking for all visible Frames. We can be sure to return a Frame from this method even if null is passed in.

  Parameters:
    `parent` - a component to find the frame of.
  Returns:
    The parent Frame

### getDialog

    public static Dialog getDialog(Component com)

  Find the parent Frame

  Parameters:
    `com` - a component to find the frame of.
  Returns:
    The parent Frame

### centerOnScreen

    public static void centerOnScreen(Window win)

  Move the specified window to the center of the screen. It is the programmer's responsibility to ensure that the window fits on the screen.

  Parameters:
    `win` - The window to be moved

### setSize

    public static int setSize(Window win,
                              Dimension requestedDim)

  Set the size of the window, but no bigger than the screen. If the platform supports it, this may maximize the window.

  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.

  Parameters:
    `win` - the window to resize
    `requestedDim` - how wide and tall to make the window, if possible
  Returns:
    whether the window has been maximized horizontally (Frame.MAXIMIZED_HORIZ), vertically (Frame.MAXIMIZED_VERT

### setSize

    public static void setSize(Window win,
                               float percentOfScreen)

  Set the window size relative to the current screen size.

  Parameters:
    `win` - The window to resize
    `percentOfScreen` - The amount of space that the window should take up

### defaultDesktopSize

    public static void defaultDesktopSize(Window win)

  Set the size of the main window to a default size.

  Parameters:
    `win` - The window to resize

### maximizeWindow

    public static void maximizeWindow(Window win)

  Maximize the specified window. It would be good if we could detect where the taskbar was and not obscure it ...

  Parameters:
    `win` - The window to be moved

### refresh

    public static void refresh(Component c)

  Cause a component to refresh its contents when it is changed by the program and needs to be redrawn.

  Parameters:
    `c` - the component to refresh

### restrainedRePack

    public static void restrainedRePack(Window win)

  A more restricted version of pack() for component responding to live component tweaks. Assuming that the window already has a sensible on screen size, do a pack, but don't let the window grow or shrink by more than 10%.

  Parameters:
    `win` - The window to be packed

### restrainedPack

    public 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. Since this is a 'first time only' pack we are only concerned with screen size, and not any growths/shrinkages like restrainedRePack(Window).

  Parameters:
    `win` - The window to be packed
    `maxx` - The maximum fraction (0.0 to 1.0) of the screen to be taken up horizontally
    `maxy` - The maximum fraction (0.0 to 1.0) of the screen to be taken up vertically
  See Also:
    `restrainedRePack(Window)`

### enforceMinimumSize

    public static void enforceMinimumSize(Component comp,
                                          int min_width,
                                          int min_height)

  Set the size of a component

### getText

    public static String getText(Component comp)

  Attempts to get the text from a generic Component. The Components that we can get some text from include:
  - JTextComponent
  - JLabel
  - AbstractButton
  - JComboBox
  - JToolTip
  - TextComponent
  - Button
  - Label
  - JScrollPane (recurse using the View) The others are done using toString()

  Parameters:
    `comp` - The object containing the needed text.

### applyDefaultOrientation

    public static void applyDefaultOrientation(Component comp)

  Recursively apply default component orientation to the component and all it contains.

  Parameters:
    `comp` - the root of the tree to which orientation needs to be applied

### applyOrientation

    public static void applyOrientation(Component comp,
                                        boolean ltr)

  Recursively apply component orientation to the component and all it contains.

  Parameters:
    `comp` - the root of the tree to which orientation needs to be applied
    `ltr` - whether the orientation is left to right or not.

### applyOrientation

    public static void applyOrientation(Component comp,
                                        ComponentOrientation orientation)

  Recursively apply component orientation to the component and all it contains.

  Parameters:
    `comp` - the root of the tree to which orientation needs to be applied
    `orientation` - the orientation to be applied

### flatten

    public static JButton flatten(JButton button)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2015
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD