public class GuiUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
SETTINGS_FILENAME |
Modifier and Type | Method and Description |
---|---|
static void |
addKeyListenerRecursive(Component component,
KeyListener listener) |
static void |
addResizeListener(Program program)
Sets up the given program so that its componentResized method will be
called whenever the window resizes.
|
static void |
centerWindow(Window window) |
static void |
centerWindowWithin(Window window,
Component parent) |
static JButton |
createButton(String text,
char mnemonic,
ActionListener listener) |
static JButton |
createButton(String text,
char mnemonic,
ActionListener listener,
Container container) |
static JButton |
createButton(String text,
String actionCommand,
char mnemonic,
ActionListener listener) |
static JButton |
createButton(String text,
String actionCommand,
char mnemonic,
ActionListener listener,
Container container) |
static JButton |
createButton(String text,
String actionCommand,
String icon,
char mnemonic,
ActionListener listener) |
static JButton |
createButton(String text,
String actionCommand,
String icon,
char mnemonic,
ActionListener listener,
Container container) |
static ButtonGroup |
createButtonGroup(ActionListener listener,
String... items) |
static JCheckBox |
createCheckBox(String actionCommand,
ActionListener listener) |
static JCheckBox |
createCheckBox(String actionCommand,
boolean checked,
ActionListener listener) |
static JCheckBox |
createCheckBox(String actionCommand,
char mnemonic,
ActionListener listener,
Container container) |
static JCheckBox |
createCheckBox(String actionCommand,
char mnemonic,
boolean checked) |
static JCheckBox |
createCheckBox(String actionCommand,
char mnemonic,
boolean checked,
ActionListener listener) |
static JCheckBox |
createCheckBox(String actionCommand,
char mnemonic,
boolean checked,
ActionListener listener,
Container container) |
static JCheckBox |
createCheckBox(String text,
String actionCommand,
char mnemonic,
ActionListener listener) |
static JCheckBox |
createCheckBox(String text,
String actionCommand,
char mnemonic,
boolean checked,
ActionListener listener) |
static JCheckBox |
createCheckBox(String text,
String actionCommand,
char mnemonic,
boolean checked,
ActionListener listener,
Container container) |
static JCheckBoxMenuItem |
createCheckBoxMenuItem(String text,
ActionListener listener,
JMenu menu) |
static JCheckBoxMenuItem |
createCheckBoxMenuItem(String text,
boolean checked,
ActionListener listener,
JMenu menu) |
static JCheckBoxMenuItem |
createCheckBoxMenuItem(String text,
char mnemonic,
boolean checked,
ActionListener listener,
JMenu menu) |
static JComboBox |
createComboBox(String actionCommand,
ActionListener listener,
String... items) |
static JComboGroupBox |
createComboGroupBox(String actionCommand,
ActionListener listener,
String... items) |
static JLabel |
createLabel(String text,
int width) |
static JLabel |
createLabel(String text,
int width,
boolean rightAligned) |
static JMenu |
createMenu(String text,
char mnemonic,
JMenuBar bar) |
static JMenu |
createMenu(String text,
JMenuBar bar) |
static JMenuItem |
createMenuItem(String text,
ActionListener listener,
JMenu menu) |
static JMenuItem |
createMenuItem(String text,
char mnemonic,
ActionListener listener,
JMenu menu) |
static JPanel |
createPanel(Component... components) |
static JPanel |
createPanel(LayoutManager layout,
Component... components) |
static JRadioButton |
createRadioButton(String text,
char mnemonic,
boolean selected,
ButtonGroup group,
ActionListener listen,
Container panel) |
static JSlider |
createSlider(int min,
int max,
int initial,
int majorTick,
int minorTick,
ChangeListener listen,
Container panel) |
static void |
errorDialog(Component comp,
String text) |
static void |
errorDialog(Component comp,
String text,
Throwable th) |
static void |
errorDialog(Component comp,
Throwable th) |
static void |
errorDialog(String text) |
static void |
errorDialog(Throwable th) |
static Icon |
extractOptionPaneIcon(String text) |
static void |
forgetWindowLocation(Frame window) |
static <C extends Component> |
getAncestor(Component comp,
Class<C> type)
Looks upward at parent containers of the given component until it finds one of the given type or
any subclass of the given type, and returns it.
|
static <JC extends JComponent> |
getDescendent(Container container,
Class<JC> type)
Returns first found descendent of given type within the given container; null if not found.
|
static <JC extends JComponent> |
getDescendents(Container container,
Class<JC> type) |
static FileFilter |
getExtensionFileFilter(String description,
String... extensions) |
static void |
growFont(JComponent button) |
static void |
growFont(JComponent button,
int amount) |
static void |
heighten(JComponent component,
int px) |
static void |
loadWindowLocation(Frame window) |
static void |
pad(JComponent component,
int w,
int h) |
static void |
printComponentHierarchy(Component comp) |
static void |
rememberWindowLocation(Frame window) |
static void |
setPreferredHeight(JComponent comp,
int height) |
static void |
setPreferredWidth(JComponent comp,
int width) |
static void |
setSystemLookAndFeel() |
static void |
shiftPreferredSize(JComponent comp,
int dw,
int dh) |
static void |
shrinkFont(JComponent button) |
static void |
shrinkFont(JComponent button,
int amount) |
static void |
widen(JComponent component,
int px) |
public static final String SETTINGS_FILENAME
public static void addKeyListenerRecursive(Component component, KeyListener listener)
public static void addResizeListener(Program program)
program
- the program to listen toClassCastException
- if the given program does not implement the
ResizeListener interface.public static void centerWindow(Window window)
public static JButton createButton(String text, char mnemonic, ActionListener listener)
public static JButton createButton(String text, char mnemonic, ActionListener listener, Container container)
public static JButton createButton(String text, String actionCommand, char mnemonic, ActionListener listener)
public static JButton createButton(String text, String actionCommand, char mnemonic, ActionListener listener, Container container)
public static JButton createButton(String text, String actionCommand, String icon, char mnemonic, ActionListener listener)
public static JButton createButton(String text, String actionCommand, String icon, char mnemonic, ActionListener listener, Container container)
public static ButtonGroup createButtonGroup(ActionListener listener, String... items)
public static JCheckBox createCheckBox(String actionCommand, ActionListener listener)
public static JCheckBox createCheckBox(String text, String actionCommand, char mnemonic, ActionListener listener)
public static JCheckBox createCheckBox(String actionCommand, boolean checked, ActionListener listener)
public static JCheckBox createCheckBox(String actionCommand, char mnemonic, boolean checked)
public static JCheckBox createCheckBox(String actionCommand, char mnemonic, boolean checked, ActionListener listener)
public static JCheckBox createCheckBox(String text, String actionCommand, char mnemonic, boolean checked, ActionListener listener)
public static JCheckBox createCheckBox(String actionCommand, char mnemonic, ActionListener listener, Container container)
public static JCheckBox createCheckBox(String actionCommand, char mnemonic, boolean checked, ActionListener listener, Container container)
public static JCheckBox createCheckBox(String text, String actionCommand, char mnemonic, boolean checked, ActionListener listener, Container container)
public static JComboBox createComboBox(String actionCommand, ActionListener listener, String... items)
public static JComboGroupBox createComboGroupBox(String actionCommand, ActionListener listener, String... items)
public static JMenuItem createMenuItem(String text, ActionListener listener, JMenu menu)
public static JMenuItem createMenuItem(String text, char mnemonic, ActionListener listener, JMenu menu)
public static JCheckBoxMenuItem createCheckBoxMenuItem(String text, ActionListener listener, JMenu menu)
public static JCheckBoxMenuItem createCheckBoxMenuItem(String text, boolean checked, ActionListener listener, JMenu menu)
public static JCheckBoxMenuItem createCheckBoxMenuItem(String text, char mnemonic, boolean checked, ActionListener listener, JMenu menu)
public static JPanel createPanel(LayoutManager layout, Component... components)
public static JRadioButton createRadioButton(String text, char mnemonic, boolean selected, ButtonGroup group, ActionListener listen, Container panel)
public static JSlider createSlider(int min, int max, int initial, int majorTick, int minorTick, ChangeListener listen, Container panel)
public static FileFilter getExtensionFileFilter(String description, String... extensions)
public static <C extends Component> C getAncestor(Component comp, Class<C> type)
public static <JC extends JComponent> JC getDescendent(Container container, Class<JC> type)
public static <JC extends JComponent> Set<JC> getDescendents(Container container, Class<JC> type)
public static void errorDialog(String text)
public static void errorDialog(Throwable th)
public static void forgetWindowLocation(Frame window)
public static void growFont(JComponent button)
public static void growFont(JComponent button, int amount)
public static void loadWindowLocation(Frame window)
public static void pad(JComponent component, int w, int h)
public static void printComponentHierarchy(Component comp)
public static void rememberWindowLocation(Frame window)
public static void setSystemLookAndFeel()
public static void setPreferredWidth(JComponent comp, int width)
public static void setPreferredHeight(JComponent comp, int height)
public static void shiftPreferredSize(JComponent comp, int dw, int dh)
public static void shrinkFont(JComponent button)
public static void shrinkFont(JComponent button, int amount)
public static void heighten(JComponent component, int px)
public static void widen(JComponent component, int px)