public class GUI
extends java.lang.Object
Any class calling these functions should implement
ActionListener, if an ActionListener has
to be set, or ItemListener if an
ItemListener has to be set.
Also, such an ActionListener or ItemListener needs
to be passed as (the last) parameter.
Typical usage:
aPanel.add(GUI.buildButton("Name", 'X', "KeyPressed", this));
This class also defines some default values for minimum, maximum and
preferred size for a number of Components, as well as default
Fonts.
ActionListener,
ItemListener,
KeyEvent,
Component,
Dimension,
Font,
JButton,
JCheckBox,
JComboBox,
JLabel,
JMenu,
JMenuItem,
JRadioButton,
JTextField,
EtchedBorder,
TitledBorder| Modifier and Type | Field and Description |
|---|---|
static java.awt.Dimension |
BUTTON_DEFAULT_SIZE |
static java.awt.Font |
BUTTON_FONT |
static java.awt.Dimension |
BUTTON_MAXIMUM_SIZE |
static java.awt.Dimension |
BUTTON_MINIMUM_SIZE |
static java.awt.Color |
TEXT_FIELD_COLOR |
static java.awt.Dimension |
TEXT_FIELD_SIZE |
static java.awt.Font |
TEXT_FONT |
static java.awt.Dimension |
WINDOW_DEFAULT_SIZE |
static java.awt.Dimension |
WINDOW_MINIMUM_SIZE |
| Modifier and Type | Method and Description |
|---|---|
static javax.swing.border.Border |
buildBorder(java.lang.String theTitle)
Creates a
TitledBorder, using an
EtchedBorder, some of the
defaults defined in this class, and the supplied title. |
static javax.swing.JButton |
buildButton(java.lang.String theName,
int theMnemonic,
java.lang.String theActionCommand,
java.awt.event.ActionListener theClass)
Creates a
JButton, using some of the defaults
defined in this class, and the supplied parameters. |
static javax.swing.JButton |
buildButton(java.lang.String theName,
java.lang.String theActionCommand,
java.awt.event.ActionListener theClass)
Creates a
JButton, using some of the defaults
defined in this class, and the supplied parameters. |
static javax.swing.JCheckBox |
buildCheckBox(java.lang.String theName,
java.awt.event.ItemListener theClass)
Creates an initially unselected
JCheckBox, using
some of the defaults defined in this class, and the supplied
parameters. |
static javax.swing.JComboBox<?> |
buildComboBox(java.lang.Object[] theItems,
java.awt.event.ActionListener theClass)
Creates a
JComboBox, using some of the defaults
defined in this class, and the supplied parameters. |
static javax.swing.JLabel |
buildLabel(java.lang.String theName,
java.awt.Component theComponent)
Creates a
JLabel, using some of the defaults
defined in this class, and the supplied parameters. |
static javax.swing.JMenu |
buildMenu(java.lang.String theName,
int theMnemonic)
Creates a
JMenu, using some of the defaults
defined in this class, and the supplied parameters. |
static javax.swing.JMenuItem |
buildMenuItem(java.lang.String theName,
int theMnemonic,
java.lang.String theActionCommand,
java.awt.event.ActionListener theClass)
Creates a
JMenuItem, using some of the defaults
defined in this class, and the supplied parameters. |
static javax.swing.JRadioButton |
buildRadioButton(java.lang.String theName,
java.awt.event.ActionListener theClass)
Creates an unselected
JRadioButton, using some of
the defaults defined in this class, and the supplied parameters. |
static javax.swing.JTextField |
buildTextField(java.lang.String theText)
Creates a
JTextField, using some of the defaults
defined in this class, and the specified text. |
public static final java.awt.Dimension WINDOW_MINIMUM_SIZE
public static final java.awt.Dimension WINDOW_DEFAULT_SIZE
public static final java.awt.Font TEXT_FONT
public static final java.awt.Font BUTTON_FONT
public static final java.awt.Dimension TEXT_FIELD_SIZE
public static final java.awt.Dimension BUTTON_DEFAULT_SIZE
public static final java.awt.Dimension BUTTON_MINIMUM_SIZE
public static final java.awt.Dimension BUTTON_MAXIMUM_SIZE
public static final java.awt.Color TEXT_FIELD_COLOR
public static javax.swing.JButton buildButton(java.lang.String theName,
int theMnemonic,
java.lang.String theActionCommand,
java.awt.event.ActionListener theClass)
JButton, using some of the defaults
defined in this class, and the supplied parameters.theName - The text of the button.theMnemonic - The key code which represents the mnemonic.theActionCommand - The action command for the button.theClass - The ActionListener to be added.JButton.JButton,
KeyEvent,
ActionListenerpublic static javax.swing.JButton buildButton(java.lang.String theName,
java.lang.String theActionCommand,
java.awt.event.ActionListener theClass)
JButton, using some of the defaults
defined in this class, and the supplied parameters.theName - The text of the button.theActionCommand - The action command for the button.theClass - The ActionListener to be added.JButton.JButton,
ActionListenerpublic static javax.swing.JCheckBox buildCheckBox(java.lang.String theName,
java.awt.event.ItemListener theClass)
JCheckBox, using
some of the defaults defined in this class, and the supplied
parameters.theName - The text of the check box.theClass - The ItemListener to be added.JCheckBox.JCheckBox,
ItemListenerpublic static javax.swing.JComboBox<?> buildComboBox(java.lang.Object[] theItems,
java.awt.event.ActionListener theClass)
JComboBox, using some of the defaults
defined in this class, and the supplied parameters.
By default the first item in the array (and therefore the data model) becomes selected.
theItems - An array of Objects to insert into the
combo box.theClass - The ActionListener to be added.JComboBox.JComboBox,
ActionListenerpublic static javax.swing.JLabel buildLabel(java.lang.String theName,
java.awt.Component theComponent)
JLabel, using some of the defaults
defined in this class, and the supplied parameters.theName - The text to be displayed by the label.theComponent - The Component this label is for, or
null if the label is not the label for a
Component.JLabel.JLabel,
Componentpublic static javax.swing.JRadioButton buildRadioButton(java.lang.String theName,
java.awt.event.ActionListener theClass)
JRadioButton, using some of
the defaults defined in this class, and the supplied parameters.theName - The String displayed on the radio button.theClass - The ActionListener to be added.JRadioButton.JRadioButton,
ActionListenerpublic static javax.swing.JTextField buildTextField(java.lang.String theText)
JTextField, using some of the defaults
defined in this class, and the specified text.theText - The text to be displayed, or null.JTextField.JTextFieldpublic static javax.swing.border.Border buildBorder(java.lang.String theTitle)
TitledBorder, using an
EtchedBorder, some of the
defaults defined in this class, and the supplied title.theTitle - The title the border should display.TitledBorder.TitledBorderpublic static javax.swing.JMenu buildMenu(java.lang.String theName,
int theMnemonic)
JMenu, using some of the defaults
defined in this class, and the supplied parameters.theName - The text for the menu label.theMnemonic - The key code which represents the mnemonic.JMenu.JMenu,
KeyEventpublic static javax.swing.JMenuItem buildMenuItem(java.lang.String theName,
int theMnemonic,
java.lang.String theActionCommand,
java.awt.event.ActionListener theClass)
JMenuItem, using some of the defaults
defined in this class, and the supplied parameters.theName - The text of the JMenuItem.theMnemonic - The key code which represents the mnemonic.theActionCommand - The action command for the JmenuItem.theClass - The ActionListener to be added.JMenuItem.JMenuItem,
KeyEvent,
ActionListener