lisken.uitoolbox
Class UItoolbox

java.lang.Object
  extended by lisken.uitoolbox.UItoolbox

public class UItoolbox
extends java.lang.Object

Provides a set of convenience methods for user interfaces.


Constructor Summary
UItoolbox()
           
 
Method Summary
static void addExitOnEscape(javax.swing.RootPaneContainer container)
          Registers an ActionListener with the root pane of a container so that the program exits upon pressing the escape key.
static void addLabel(javax.swing.JSlider slider, int value)
           
static void centerOnScreen(java.awt.Component component)
          Centers a component on the screen.
static void focusWindow(java.awt.Window window)
          Tries to focus a window.
static java.lang.String getTitle(java.awt.Window window)
          Returns the title of a window if it's a Frame or a Dialog or null otherwise.
static void invokeAndWait(java.lang.Runnable runner)
           
static void moveComponentNearComponent(java.awt.Component component, java.awt.Component nearComponent)
          Moves one component to another component.
static void pack(java.awt.Component c)
          Packs the window that contains a certain component.
static void restrictScrollPaneToScreenPart(javax.swing.JScrollPane scrollPane, float widthPart, float heightPart)
           
static java.awt.Dimension restrictSizeToScreenPart(java.awt.Component component, float widthPart, float heightPart)
          Returns the dimension of this component restricted to a certain percentage of the screen size.
static java.awt.Dimension restrictSizeToScreenPart(java.awt.Dimension originalSize, float widthPart, float heightPart)
          Restricts a dimension to a certain percentage of the screen size.
static void setmaxToPref(javax.swing.JComponent component)
          Sets the maximum size of a component to its preferred size.
static void showTextInfo(java.lang.String title, java.lang.String info)
          Shows a dialog with info and the specified title.
static void showTextInfo(java.lang.String title, java.lang.String info, boolean monospaced)
          Shows a dialog with info, the specified title and the specified font type.
static void showTextInfo(java.lang.String title, java.lang.String info, boolean monospaced, java.awt.Component nearComponent)
          Shows a dialog with info and the specified title near the given component.
static void showTextInfo(java.lang.String title, java.lang.String info, java.awt.Component nearComponent)
          Shows a dialog with info and the specified title near the given component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UItoolbox

public UItoolbox()
Method Detail

addExitOnEscape

public static void addExitOnEscape(javax.swing.RootPaneContainer container)
Registers an ActionListener with the root pane of a container so that the program exits upon pressing the escape key.

Parameters:
container - The container which should respond to the escape key.

showTextInfo

public static void showTextInfo(java.lang.String title,
                                java.lang.String info)
Shows a dialog with info and the specified title.

Parameters:
title - The title of the dialog.
info - The info to be shown.

showTextInfo

public static void showTextInfo(java.lang.String title,
                                java.lang.String info,
                                boolean monospaced)
Shows a dialog with info, the specified title and the specified font type.

Parameters:
title - The title of the dialog.
info - The info to be shown.
monospaced - The font type of the info.

showTextInfo

public static void showTextInfo(java.lang.String title,
                                java.lang.String info,
                                java.awt.Component nearComponent)
Shows a dialog with info and the specified title near the given component.

Parameters:
title - The title of the dialog.
info - The info to be shown.
nearComponent - The component in which proximity the dialog should be shown.

showTextInfo

public static void showTextInfo(java.lang.String title,
                                java.lang.String info,
                                boolean monospaced,
                                java.awt.Component nearComponent)
Shows a dialog with info and the specified title near the given component.

Parameters:
title - The title of the dialog.
info - The info to be shown.
monospaced - The font type of the info.
nearComponent - The component in which proximity the dialog should be shown.

moveComponentNearComponent

public static void moveComponentNearComponent(java.awt.Component component,
                                              java.awt.Component nearComponent)
Moves one component to another component.

Parameters:
component - The component which will be moved.
nearComponent - The component to which will be moved.

centerOnScreen

public static void centerOnScreen(java.awt.Component component)
Centers a component on the screen.

Parameters:
component - The component to be centered on the screen.

setmaxToPref

public static void setmaxToPref(javax.swing.JComponent component)
Sets the maximum size of a component to its preferred size.

Parameters:
component - The component for which the maximum size must be set.

pack

public static void pack(java.awt.Component c)
Packs the window that contains a certain component.

Parameters:
c - The component which parent window should be packed.

restrictSizeToScreenPart

public static java.awt.Dimension restrictSizeToScreenPart(java.awt.Dimension originalSize,
                                                          float widthPart,
                                                          float heightPart)
Restricts a dimension to a certain percentage of the screen size. If the original dimension is larger than the given percentages of the screen size, then it will be truncated. The percentages need to be given as floats where 1.0f means 100%.

Parameters:
originalSize - The dimension that needs to be restricted.
widthPart - The percentage of the screen width.
heightPart - The percentage of the screen height.
Returns:
The restricted dimension.

restrictSizeToScreenPart

public static java.awt.Dimension restrictSizeToScreenPart(java.awt.Component component,
                                                          float widthPart,
                                                          float heightPart)
Returns the dimension of this component restricted to a certain percentage of the screen size.

Parameters:
component - The component for which the dimension needs to be restricted.
widthPart - The percentage of the screen width.
heightPart - The percentage of the screen height.
Returns:
The restricted dimension.
See Also:
restrictSizeToScreenPart(java.awt.Dimension, float, float)

restrictScrollPaneToScreenPart

public static void restrictScrollPaneToScreenPart(javax.swing.JScrollPane scrollPane,
                                                  float widthPart,
                                                  float heightPart)

addLabel

public static void addLabel(javax.swing.JSlider slider,
                            int value)

invokeAndWait

public static void invokeAndWait(java.lang.Runnable runner)

getTitle

public static java.lang.String getTitle(java.awt.Window window)
Returns the title of a window if it's a Frame or a Dialog or null otherwise.

Parameters:
window - The window for which the title must be returned.
Returns:
The title of window or null if not applicable.

focusWindow

public static void focusWindow(java.awt.Window window)
Tries to focus a window.

Parameters:
window - The window that needs to be focussed.