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 [joe at eireneh dot com]
See Also:
  `for license details. The copyright to this program is held by it's authors.`

Field Summary
`private static Logger` | `log` The log stream

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

Method Summary
`static void` | `centerWindow(Window win)` Move the specified window to the centre of the screen.
`static void` | `enforceMinimumSize(Component comp, int min_width, int min_height)` Set the size of a component
`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 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.

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

Field Detail

### log

    private static final Logger log

  The log stream

Constructor Detail

### GuiUtil

    private GuiUtil()

  Prevent Instansiation

Method Detail

### getIcon

    public static ImageIcon getIcon(String name)

  Returns the Icon associated with the name from the resources. The resouce 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

### 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

### centerWindow

    public static void centerWindow(Window win)

  Move the specified window to the centre 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

### 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.

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