com.jeta.open.gui.utils
Class JETAToolbox

java.lang.Object
  extended by com.jeta.open.gui.utils.JETAToolbox

public class JETAToolbox
extends Object

Some common utility functions for GUI stuff.


Field Summary
static String APPLICATION_FRAME
           
static String WINDOWS_LF
           
 
Constructor Summary
JETAToolbox()
           
 
Method Summary
static void addItems(JComboBox cbox, Object[] items)
          Adds an array or collection of items to a combo box
static int calculateAverageTextWidth(Component comp, int numCharacters)
          Calculates the width of an average string of text.
static void calculateReasonableComponentSize(Dimension d)
          Sets the size of the dimension to some reasonable value.
static void centerFrame(Window frame, float xpctWidth, float ypctWidth)
          This method centers and sizes a frame window on the screen.
static void centerWindow(Window frame)
          This method centers a window window on the screen.
static void centerWindowChangeWidth(Window frame, float xpctWidth)
          This method centers a window window and changes the width on the screen.
static void copyToClipboard(String str)
          Copies to the clipboard the given string
static Dialog createDialog(Class dlgclass, Component owner, boolean bModal)
          This method creates a dialog of the type class.
static int getFrameBorderThickness()
           
static int getTitleBarHeight()
           
static JETADialog invokeDialog(JETAPanel view, Component owner, String title)
          Creates and displays a model JETADialog using the given view as the content pane.
static JETADialog invokeDialog(JETAPanel view, Component owner, String title, JComponent initialFocus)
          Creates and displays a model JETADialog using the given view as the content pane.
static boolean isAquaLookAndFeel()
          Returns true if running OS X Aqua look and feel.
static boolean isOSX()
           
static boolean isWindows()
           
static boolean isWindowsLookAndFeel()
           
static void setReasonableWindowSize(Component window, Dimension d)
          Sets the size of the given window to the passed in dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_FRAME

public static final String APPLICATION_FRAME
See Also:
Constant Field Values

WINDOWS_LF

public static final String WINDOWS_LF
See Also:
Constant Field Values
Constructor Detail

JETAToolbox

public JETAToolbox()
Method Detail

addItems

public static void addItems(JComboBox cbox,
                            Object[] items)
Adds an array or collection of items to a combo box


calculateAverageTextWidth

public static int calculateAverageTextWidth(Component comp,
                                            int numCharacters)
Calculates the width of an average string of text.

Parameters:
comp - the component whose font metrics will determine the width
numCharacters - the number of characters to use to calculate the length

calculateReasonableComponentSize

public static void calculateReasonableComponentSize(Dimension d)
Sets the size of the dimension to some reasonable value. If the given dimension is larger than the screen size, then we set the window to 80% of the screen size. Otherwise, we leave it alone

Parameters:
d - the dimension of the window to set

centerFrame

public static void centerFrame(Window frame,
                               float xpctWidth,
                               float ypctWidth)
This method centers and sizes a frame window on the screen. The caller must pass the x and y percentages of screen width/height.


centerWindow

public static void centerWindow(Window frame)
This method centers a window window on the screen. The caller must pass the x and y percentages of screen width/height.


centerWindowChangeWidth

public static void centerWindowChangeWidth(Window frame,
                                           float xpctWidth)
This method centers a window window and changes the width on the screen. The caller must pass the x percentages of screen width. The height remains unchanged


copyToClipboard

public static void copyToClipboard(String str)
Copies to the clipboard the given string


createDialog

public static Dialog createDialog(Class dlgclass,
                                  Component owner,
                                  boolean bModal)
This method creates a dialog of the type class. It assumes that the dialog will have constructors that have the following form: ctor( JDialog owner, boolean bmodal ) ctor( Frame owner, boolean bmodal ) This method interogates the owner object. If this object is a JDialog or Frame, then we call the appropriate constructor for the class. If this object is a JComponent, then we get the objects owner window and determine if that is a JDialog or Frame.

Parameters:
dlgclass - the class of the dialog we want to create
owner - the owner of the new dialog. This object can be indirectly an owner. For example, you can pass in a JPanel as the owner. This method will detect this and get the appropriate owner of the JPanel
bModal - true if you want the dialog to be modal

getFrameBorderThickness

public static int getFrameBorderThickness()
Returns:
the thickness (in pixels) of the border on a frame or dialog window Currently, this is hard coded until I figure out a way to get this value.

getTitleBarHeight

public static int getTitleBarHeight()
Returns:
the height (in pixels) of the titlebar on a frame or dialog window Currently, this is hard coded until I figure out a way to get this value.

invokeDialog

public static JETADialog invokeDialog(JETAPanel view,
                                      Component owner,
                                      String title)
Creates and displays a model JETADialog using the given view as the content pane. The dialog is centered on the screen and it's modal parent is set to null.


invokeDialog

public static JETADialog invokeDialog(JETAPanel view,
                                      Component owner,
                                      String title,
                                      JComponent initialFocus)
Creates and displays a model JETADialog using the given view as the content pane. The dialog is centered on the screen and it's modal parent is set to null.

Parameters:
view - the main content panel for the dialog
title - the dialog's title
initialFocus - the component that will have the initial focus

isAquaLookAndFeel

public static boolean isAquaLookAndFeel()
Returns true if running OS X Aqua look and feel.


isOSX

public static boolean isOSX()
Returns:
true if running Mac OS X

isWindows

public static boolean isWindows()
Returns:
true if running Windows

isWindowsLookAndFeel

public static boolean isWindowsLookAndFeel()
Returns:
true if we are currently in the windows look and feel. This L&F has different focus issues with the popup

setReasonableWindowSize

public static void setReasonableWindowSize(Component window,
                                           Dimension d)
Sets the size of the given window to the passed in dimension. However, if the given dimension is larger than the screen size, then we set the window to 80% of the screen size

Parameters:
window - the window whose size we are setting
d - the dimension of the window to set


Copyright © 2005-2007 Jeff Tassin & Todd Viegut. All Rights Reserved.