prefuse.util.ui
Class UILib

java.lang.Object
  extended by prefuse.util.ui.UILib

public class UILib
extends java.lang.Object

Library routines for user interface tasks.

Author:
jeffrey heer

Method Summary
static void addGlue(javax.swing.JComponent b, boolean horiz)
          Add a glue, or variable spacing, to a UI component
static void addGlue(javax.swing.JComponent b, int layout)
          Add a glue, or variable spacing, to a UI component
static void addStrut(javax.swing.JComponent b, boolean horiz, int size)
          Add a strut, or rigid spacing, to a UI component
static void addStrut(javax.swing.JComponent b, int layout, int size)
          Add a strut, or rigid spacing, to a UI component
static int getAxis(javax.swing.JComponent c, int layout)
          Resolve the axis type of a component, given a layout orientation
static javax.swing.Box getBox(java.awt.Component[] c, boolean horiz, int margin, int spacing)
          Convenience method for creating a Box user interface widget container.
static javax.swing.Box getBox(java.awt.Component[] c, boolean horiz, int margin1, int margin2, int spacing)
          Convenience method for creating a Box user interface widget container.
static boolean isButtonPressed(java.awt.event.InputEvent e, int button)
          Indicates if a given mouse button is being pressed.
static void setColor(java.awt.Component c, java.awt.Color back, java.awt.Color fore)
          Sets the foreground and background color for a component and all components contained within it.
static void setFont(java.awt.Component c, java.awt.Font font)
          Sets the font for a component and all components contained within it.
static void setPlatformLookAndFeel()
          Set the look and feel of Java Swing user interface components to match that of the platform (Windows, Mac, Linux, etc) on which it is currently running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isButtonPressed

public static boolean isButtonPressed(java.awt.event.InputEvent e,
                                      int button)
Indicates if a given mouse button is being pressed.

Parameters:
e - the InputEvent to check
button - the mouse button to look for
Returns:
true if the button is being pressed, false otherwise
See Also:
Control

setPlatformLookAndFeel

public static final void setPlatformLookAndFeel()
Set the look and feel of Java Swing user interface components to match that of the platform (Windows, Mac, Linux, etc) on which it is currently running.


getBox

public static javax.swing.Box getBox(java.awt.Component[] c,
                                     boolean horiz,
                                     int margin,
                                     int spacing)
Convenience method for creating a Box user interface widget container.

Parameters:
c - an array of components to include in the box
horiz - indicated is the box should be horizontal (true) or vertical (false)
margin - the margins, in pixels, to use on the sides of the box
spacing - the minimum spacing, in pixels, to use between components
Returns:
a new Box instance with the given properties.
See Also:
Box

getBox

public static javax.swing.Box getBox(java.awt.Component[] c,
                                     boolean horiz,
                                     int margin1,
                                     int margin2,
                                     int spacing)
Convenience method for creating a Box user interface widget container.

Parameters:
c - an array of components to include in the box
horiz - indicated is the box should be horizontal (true) or vertical (false)
margin1 - the margin, in pixels, for the left or top side
margin2 - the margin, in pixels, for the right or bottom side
spacing - the minimum spacing, in pixels, to use between components
Returns:
a new Box instance with the given properties.
See Also:
Box

addStrut

public static void addStrut(javax.swing.JComponent b,
                            boolean horiz,
                            int size)
Add a strut, or rigid spacing, to a UI component

Parameters:
b - the component to add the strut to, should be either a Box or a Container using a BoxLayout.
horiz - indicates if the strust should horizontal (true) or vertical (false)
size - the length, in pixels, of the strut

addGlue

public static void addGlue(javax.swing.JComponent b,
                           boolean horiz)
Add a glue, or variable spacing, to a UI component

Parameters:
b - the component to add the glue to, should be either a Box or a Container using a BoxLayout.
horiz - indicates if the glue should horizontal (true) or vertical (false)

addStrut

public static void addStrut(javax.swing.JComponent b,
                            int layout,
                            int size)
Add a strut, or rigid spacing, to a UI component

Parameters:
b - the component to add the strut to, should be either a Box or a Container using a BoxLayout.
layout - the desired layout orientation of the strut. One of BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS, or BoxLayout.PAGE_AXIS.
size - the length, in pixels, of the strut

addGlue

public static void addGlue(javax.swing.JComponent b,
                           int layout)
Add a glue, or variable spacing, to a UI component

Parameters:
b - the component to add the glue to, should be either a Box or a Container using a BoxLayout.
layout - the desired layout orientation of the glue. One of BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS, or BoxLayout.PAGE_AXIS.

getAxis

public static int getAxis(javax.swing.JComponent c,
                          int layout)
Resolve the axis type of a component, given a layout orientation

Parameters:
c - a Swing Component, should be either a Box or a Container using a BoxLayout.
layout - the layout orientation of the component. One of BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS, or BoxLayout.PAGE_AXIS.
Returns:
one of BoxLayout.X_AXIS, or BoxLayout.Y_AXIS,

setColor

public static void setColor(java.awt.Component c,
                            java.awt.Color back,
                            java.awt.Color fore)
Sets the foreground and background color for a component and all components contained within it.

Parameters:
c - the parent component of the component subtree to set
back - the background color to set
fore - the foreground color to set

setFont

public static void setFont(java.awt.Component c,
                           java.awt.Font font)
Sets the font for a component and all components contained within it.

Parameters:
c - the parent component of the component subtree to set
font - the font to set


Copyright © 2007 Regents of the University of California