org.jtheque.utils.ui
Class SwingUtils

java.lang.Object
  extended by org.jtheque.utils.ui.SwingUtils

public final class SwingUtils
extends Object

Provide utility methods for Swing Components.

Author:
Baptiste Wicht

Method Summary
static void addFieldLengthLimit(JTextField field, int length)
          Limit the length of the field.
static void addFieldValidateAction(JComponent field, Action action)
          Add an action to execute when the validation key (Enter) is pressed.
static void centerFrame(Window frame)
          Center a frame on the screen.
static Component createButtonBar(Action... actions)
          Create a button bar for actions.
static Component createButtonBar(boolean leftAligned, Action... actions)
          Create a button bar.
static Font getDefaultFont()
          Return the default font of the application.
static JOptionPane getOptionPane(Component c)
          Return the JOptionPane parent.
static void inEdt(Runnable runnable)
          Executed the specified runnable in the EDT.
static void refresh(Component component)
          Refresh the specified component.
static void setOptionPaneValue(Component c, Object value)
          Set the option pane value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

centerFrame

public static void centerFrame(Window frame)
Center a frame on the screen.

Parameters:
frame - The frame to be centered

getOptionPane

public static JOptionPane getOptionPane(Component c)
Return the JOptionPane parent.

Parameters:
c - The component.
Returns:
The parent JOptionPane.

setOptionPaneValue

public static void setOptionPaneValue(Component c,
                                      Object value)
Set the option pane value.

Parameters:
c - The component.
value - The value to set to the JOptionPane.

createButtonBar

public static Component createButtonBar(Action... actions)
Create a button bar for actions.

Parameters:
actions - The actions to create the bar for.
Returns:
A Bar containing a button for each action.

createButtonBar

public static Component createButtonBar(boolean leftAligned,
                                        Action... actions)
Create a button bar.

Parameters:
leftAligned - A boolean flag indicating if we want a left to right alignment or not.
actions - The actions to add to the menu bar.
Returns:
The builded button bar.

addFieldValidateAction

public static void addFieldValidateAction(JComponent field,
                                          Action action)
Add an action to execute when the validation key (Enter) is pressed.

Parameters:
field - The field to validate.
action - The action to execute on validate.

addFieldLengthLimit

public static void addFieldLengthLimit(JTextField field,
                                       int length)
Limit the length of the field.

Parameters:
field - The field to limit.
length - The maximal length the field may contain.

getDefaultFont

public static Font getDefaultFont()
Return the default font of the application.

Returns:
The default font.

inEdt

public static void inEdt(Runnable runnable)
Executed the specified runnable in the EDT.

Parameters:
runnable - The runnable to run in EDT.

refresh

public static void refresh(Component component)
Refresh the specified component.

Parameters:
component - The component to refresh.


Copyright © 2010 JTheque. All Rights Reserved.