| java.lang.Object org.glasser.swing.GUIHelper
GUIHelper | public class GUIHelper (Code) | | |
Method Summary | |
public static void | buildButtonPanel(JPanel buttonPanel, Object[][] buttonConfig, ActionListener listener) | public static void | buildFormPanel(JPanel panel, Object[][] fields, int fieldWidth, int vgap, Font labelFont, Color labelForeground, boolean stretchLastRow, int lastRowHeight) This method peforms the tedious chore of constructing a form
panel consisting of JTextField objects, each with a corresponding
JLabel to its left. | public static JComponent | buildMenu(JComponent menu, Object[][] menuConfig, ActionListener listener, ChangeListener changeListener, ItemListener itemListener) Adds JMenuItems, separators and submenus to a JMenu or JPopup menu.
Parameters: menu - the menu to be configured. | public static JComponent | buildMenu(JComponent menu, Object[][] menuConfig, ActionListener listener, ChangeListener changeListener, ItemListener itemListener, ResourceBundle bundle) Adds JMenuItems, separators and submenus to a JMenu or JPopup menu.
Parameters: menu - the menu to be configured. | public static void | centerWindowOnScreen(java.awt.Window w) Centers a window on the screen. | public static void | configureToolbar(JToolBar toolBar, Object[][] toolBarConfig, String imageDir, Dimension buttonSize, ActionListener actionListener) | public static void | enterPressesWhenFocused(JButton button) After a JButton has been passed to this method, it will be invoked by the ENTER
key whenever it has the focus. | public static void | errMsg(Component parent, String msg, String title) Beeps and displays message box with error icon. | public static void | exceptionMsg(Component parent, Exception ex) Displays info about an exception in a message box. | public static void | exceptionMsg(Exception ex) Displays info about an exception in a message box. | public static JMenuItem | findMenuItemByActionCommand(MenuElement menu, String command) Searches through a tree of menus and returns the JMenuItem that has the string
"command" set as its ActionCommand. | public static JMenuItem | findMenuItemByLabelText(MenuElement menu, String labelText) Searches through a tree of menus and returns the JMenuItem that has the string
"labelText" set as its label text. | public static ImageIcon | getImageIconFromClasspath(String imageFilePath) Given the path, relative to the classpath, of an image file which is IN the classpath,
this will return an ImageIcon constructed from the given image. | public static JMenuItem[] | getMenuItems(JMenu menu) This returns an array containing all of the JMenuItems from
the given JMenu. | public static JMenuItem[] | getMenuItems(JPopupMenu menu) This returns an array containing all of the JMenuItems from
the given JPopupMenu. | public static JViewport | getViewport(Component c) | public static void | infoMsg(Component parent, String msg, String title) Beeps and displays message box with info icon. | public static void | setAllSizes(JComponent c, Dimension d) | public static void | setTabTraversal(JTextArea textArea) This method will modify the given JTextArea for Java versions 1.4.0 and above so that
pressing the tab key will shift focus away from the JTextArea, rather than insert
a tab character. | public static int | showConfirmDialog(Component parent, Object msg, String title, int optionType) | public static int | showConfirmDialog(Component parent, Object msg, String title, int optionType, int messageType) | public static void | showMessageDialog(Component parent, String msg, String title, int messageType) Beeps and displays message box with icon of given type. | public static void | warningMsg(Component parent, String msg, String title) Beeps and displays message box with a warning icon. |
FORWARD_TRAVERSAL_KEYSBACKWARD_TRAVERSAL_KEYS | static int FORWARD_TRAVERSAL_KEYSBACKWARD_TRAVERSAL_KEYS(Code) | | |
defaultMessageTitle | public static String defaultMessageTitle(Code) | | |
isJavaVersion_1_4_OrGreater | static boolean isJavaVersion_1_4_OrGreater(Code) | | |
setFocusEnableMethod | static Method setFocusEnableMethod(Code) | | |
setFocusTraversalMethod | static Method setFocusTraversalMethod(Code) | | |
buildButtonPanel | public static void buildButtonPanel(JPanel buttonPanel, Object[][] buttonConfig, ActionListener listener)(Code) | | Configures and adds JButtons to a JPanel, which is assumed to have a FlowLayout
(although other layout managers may work.)
Parameters: buttonPanel - the JPanel to which the JButtons will be added. Parameters: buttonConfig - a two-dimensional Object array, where each outer elementis an array with the following elements:- A JButton to be added
- A single-character String, which will be used to set the mnemonic for the button.
- A String representing the ActionCommand that will be set for the button.
- A String that will be set as the ToolTipText for the button
Parameters: An - ActionListener that will be passed to each JButton's addActionListener() method. |
buildFormPanel | public static void buildFormPanel(JPanel panel, Object[][] fields, int fieldWidth, int vgap, Font labelFont, Color labelForeground, boolean stretchLastRow, int lastRowHeight)(Code) | | This method peforms the tedious chore of constructing a form
panel consisting of JTextField objects, each with a corresponding
JLabel to its left. It uses a GridBagLayout to layout the components.
Parameters: panel - The JPanel to be laid out. Parameters: fields - Each member array in this NxN array is of the form:{<JTextField object>, <Label Text String>, [<Tooltip Text String>]} The String containing the label text is used to construct a JLabelfor the JTextField. If the Tooltip Text String is present (it need not be)then it will be used as the tooltip text for both the JLabel and the JTextField. Parameters: fieldWidth - if negative, this parameter is ignored, otherwise itis used as the ipadx value in the GridBagConstraints object for eachJTextField object. If the panel's width will not be determined by a layoutmanager or some other means, this parameter should be used. Parameters: vgap - the vertical gap between label/textfield rows. Parameters: labelFont - the Font that will be used for the JLabels. If null,the default font is used. Parameters: labelForeground - the color that will be used for the foreground ofthe JLabels. If null, the default color is used. Parameters: stretchLastRow - if true, the component in the last row will have it'sfill attribute set to "BOTH" so that it will stretch vertically as well ashorizontally. Parameters: lastRowHeight - this is the amount used for ipady on the last row's component.if less than 1, then the component's preferred height will be used.
|
buildMenu | public static JComponent buildMenu(JComponent menu, Object[][] menuConfig, ActionListener listener, ChangeListener changeListener, ItemListener itemListener)(Code) | | Adds JMenuItems, separators and submenus to a JMenu or JPopup menu.
Parameters: menu - the menu to be configured. If null, a JPopupMenu is intantiated and returned. Parameters: menuConfig - a array of arrays containing the information needed to configurethe menu. Each element array is used to configure a JMenuItem that is added to themenu, or a submenu. An element array must have at least one element, and may haveup to four. These elements represent:- element 0:
(REQUIRED) The String used as the text for a menu item or a submenu. If it isis for a submenu, it should begin with an underscore (_), which will be stripped off. Optionally,this element may be the String "SEPARATOR", in which case a menu separator will be inserted.- element 1:
(REQUIRED, unless element 0 is "SEPARATOR") If this row is for a JMenuItem,then this element is a string that will be set as the "actionCommand" for that JMenuItem, soActionListeners can identify which menu item was selected. If this row is for a submenu, thenthis element is another Object[][] menuConfig array that will be used to configure thesubmenu.- element 2:
(OPTIONAL) a String, the first character of which will be set as themnemonic for the menu item of submenu.- element 3:
(OPTIONAL) a String which contains a message that is sent to the StatusMessageDisplay object(which typically would be a statusbar) if one was provided, any time the menu item is passed over by the mouse.
Parameters: listener - an ActionListener that will be added to each JMenuItem. Parameters: statusDisplay - a StatusMessageDisplay object that will receive status messages from JMenuItemsthey're passed over in an open menu. This would typically be a status bar. If status messageelements are provided in any of the config array elements, this argument should be provided also. |
buildMenu | public static JComponent buildMenu(JComponent menu, Object[][] menuConfig, ActionListener listener, ChangeListener changeListener, ItemListener itemListener, ResourceBundle bundle)(Code) | | Adds JMenuItems, separators and submenus to a JMenu or JPopup menu.
Parameters: menu - the menu to be configured. If null, a JPopupMenu is intantiated and returned. Parameters: menuConfig - a array of arrays containing the information needed to configurethe menu. Each element array is used to configure a JMenuItem that is added to themenu, or a submenu. An element array must have at least one element, and may haveup to four. These elements represent:- element 0:
(REQUIRED) The String used as the text for a menu item or a submenu. If it isis for a submenu, it should begin with an underscore (_), which will be stripped off. Optionally,this element may be the String "SEPARATOR", in which case a menu separator will be inserted.- element 1:
(REQUIRED, unless element 0 is "SEPARATOR") If this row is for a JMenuItem,then this element is a string that will be set as the "actionCommand" for that JMenuItem, soActionListeners can identify which menu item was selected. If this row is for a submenu, thenthis element is another Object[][] menuConfig array that will be used to configure thesubmenu.- element 2:
(OPTIONAL) a String, the first character of which will be set as themnemonic for the menu item of submenu.- element 3:
(OPTIONAL) a String which contains a message that is sent to the StatusMessageDisplay object(which typically would be a statusbar) if one was provided, any time the menu item is passed over by the mouse.
Parameters: listener - an ActionListener that will be added to each JMenuItem. Parameters: statusDisplay - a StatusMessageDisplay object that will receive status messages from JMenuItemsthey're passed over in an open menu. This would typically be a status bar. If status messageelements are provided in any of the config array elements, this argument should be provided also. |
centerWindowOnScreen | public static void centerWindowOnScreen(java.awt.Window w)(Code) | | Centers a window on the screen. Should be used for top-level windows only. Does nothing
if any needed information is missing, or if window is larger than the screen in
either direction.
|
enterPressesWhenFocused | public static void enterPressesWhenFocused(JButton button)(Code) | | After a JButton has been passed to this method, it will be invoked by the ENTER
key whenever it has the focus. This is not the default behavior for the Metal
look-and-feel.
|
exceptionMsg | public static void exceptionMsg(Component parent, Exception ex)(Code) | | Displays info about an exception in a message box.
|
exceptionMsg | public static void exceptionMsg(Exception ex)(Code) | | Displays info about an exception in a message box.
|
findMenuItemByActionCommand | public static JMenuItem findMenuItemByActionCommand(MenuElement menu, String command)(Code) | | Searches through a tree of menus and returns the JMenuItem that has the string
"command" set as its ActionCommand.
|
findMenuItemByLabelText | public static JMenuItem findMenuItemByLabelText(MenuElement menu, String labelText)(Code) | | Searches through a tree of menus and returns the JMenuItem that has the string
"labelText" set as its label text.
|
getImageIconFromClasspath | public static ImageIcon getImageIconFromClasspath(String imageFilePath)(Code) | | Given the path, relative to the classpath, of an image file which is IN the classpath,
this will return an ImageIcon constructed from the given image.
|
getMenuItems | public static JMenuItem[] getMenuItems(JMenu menu)(Code) | | This returns an array containing all of the JMenuItems from
the given JMenu. It does not recurse through submenus.
|
getMenuItems | public static JMenuItem[] getMenuItems(JPopupMenu menu)(Code) | | This returns an array containing all of the JMenuItems from
the given JPopupMenu. It does not recurse through submenus.
|
setTabTraversal | public static void setTabTraversal(JTextArea textArea)(Code) | | This method will modify the given JTextArea for Java versions 1.4.0 and above so that
pressing the tab key will shift focus away from the JTextArea, rather than insert
a tab character. It uses reflection so that the code can be compiled and run with
versions prior to 1.4.0. Before version 1.4.0, this affect could be achieved
by overriding isManagingFocus() on the JTextArea to return false, however that no
longer works.
|
showConfirmDialog | public static int showConfirmDialog(Component parent, Object msg, String title, int optionType, int messageType)(Code) | | |
showMessageDialog | public static void showMessageDialog(Component parent, String msg, String title, int messageType)(Code) | | Beeps and displays message box with icon of given type. messageType parameter
may be JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE
or JOptionPane.ERROR_MESSAGE.
|
warningMsg | public static void warningMsg(Component parent, String msg, String title)(Code) | | Beeps and displays message box with a warning icon.
|
|
|