Class CommonUI
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Colorstatic final intstatic final intstatic Dimensionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic Dimensionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic Dimensionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic Dimensionstatic final intstatic final intstatic Dimensionstatic final String<html><p style=\"width:300px;\"> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PointadjustPopupLocationToFitScreen(int xposition, int yposition, JComponent component, Component invoker) Adjusts a desired popup location to fit within the screen, given the component's preferred size.static voidcenterComponent(Component source) Centers the Component on the screen.static voidcenterComponent(Component source, Component parent) Centers a component (source) in it's parent component.static JButtoncreateAccessoryButton(Action action) Creates a small button for the given action with a 2px margin.static BorderCreates an blank border with the displayed textstatic BordercreateBorder(String text) Creates an etched border with the displayed textstatic JButtoncreateButton(String text, ActionListener listener) static JButtoncreateButton(String text, ActionListener listener, String mnemonic) Creates a JButtonstatic JButtoncreateButton(String text, ActionListener listener, String mnemonic, String actionCommand) static JCheckBoxcreateCheckBox(String text) static JCheckBoxcreateCheckBox(String text, int mnemonic) static JCheckBoxcreateCheckBox(String text, int mnemonic, boolean selected) static JCheckBoxcreateCheckBox(String text, int mnemonic, ActionListener listener) static JCheckBoxcreateCheckBox(String text, int mnemonic, ActionListener listener, boolean selected) Create a checkboxstatic JComboBoxcreateComboBox(Object[] items, boolean editable) static JComboBoxcreateComboBox(Object[] items, ActionListener listener, boolean editable) Creates a JComboBoxstatic JLabelcreateLabel(String text) static JLabelcreateLabel(String text, int mnemonic, Component comp) Creates a label which will be displayed.static JScrollPanecreateListPane(JList list, String text) Wraps a scrollpane with and etched border and a title around a JList.static JRadioButtoncreateRadioButton(String text) static JRadioButtoncreateRadioButton(String text, int mnemonic) static JRadioButtoncreateRadioButton(String text, int mnemonic, boolean selected) static JRadioButtoncreateRadioButton(String text, int mnemonic, ActionListener listener) static JRadioButtoncreateRadioButton(String text, int mnemonic, ActionListener listener, boolean selected) Creates a Radio Buttonstatic JButtoncreateSmallButton(String text, ActionListener listener) static JButtoncreateSmallButton(String text, ActionListener listener, String mnemonic) Creates a Smaller JButtonstatic JTextFieldcreateTextField(String text) static JTextFieldcreateTextField(String text, boolean numbers) static JTextFieldcreateTextField(String text, KeyListener listener) static JTextFieldcreateTextField(String text, KeyListener listener, boolean numbers) Creates a text fieldstatic AbstractButtoncreateToolbarButton(Action action, String componentTestName) Returns a minimalized toolbar button with no text.static StringeventModifiersToString(int event) static JFramegetParentFrame(Component source) Retrieves the parent JFrame for a component.static final StringgetTooltipPrefix(int width) static final StringgetTooltipPrefixInline(int width) static voidinitButtonGroup(JRadioButton... buttons) static IntegerConverts miliseconds to secondsstatic IntegerConverts seconds to milisecondsstatic voidsetDefaultCursor(Component comp) static voidsetDropCursor(Component comp) static voidsetupCancelButton(JButton btn) Sets up the ESC-key binding for a cancel buttonstatic voidsetWaitCursor(Component comp) static DimensionsizeAndCenterOnDisplay(Window window, Dimension preferred) Sizes a window to at most the usable area of the display it is on, and centers it there.static String[]stringArrayFromString(String string) static String[]stringArrayFromString(String string, String delim) Parses the string into an array of stringsstatic StringstringFromStringArray(String[] strings) static StringstringFromStringArray(String[] strings, String delim) Takes an array of strings and returns a concatenationstatic RectangleusableBounds(Window window) The usable area of the display the given window is on: that display's bounds, less the strips the OS reserves for a taskbar, Dock or menu bar.static JPanelwrapInTitledPanel(JComponent component, String bundleKey)
-
Field Details
-
TOOLTIP_PREFIX
-
BUTTONTEXT_APPLY
-
BUTTONTEXT_OK
-
BUTTONTEXT_CANCEL
-
BUTTONTEXT_REMOVE
-
BUTTONTEXT_ADD
-
MNEMONIC_APPLY
-
MNEMONIC_OK
-
MNEMONIC_CANCEL
-
MNEMONIC_REMOVE
-
MNEMONIC_ADD
-
BUTTON_WIDTH
public static final int BUTTON_WIDTH- See Also:
-
BUTTON_HEIGHT
public static final int BUTTON_HEIGHT- See Also:
-
BUTTCON_WIDTH
public static final int BUTTCON_WIDTH- See Also:
-
BUTTCON_HEIGHT
public static final int BUTTCON_HEIGHT- See Also:
-
SM_BUTTON_WIDTH
public static final int SM_BUTTON_WIDTH- See Also:
-
SM_BUTTON_HEIGHT
public static final int SM_BUTTON_HEIGHT- See Also:
-
LABEL_WIDTH
public static final int LABEL_WIDTH- See Also:
-
LABEL_HEIGHT
public static final int LABEL_HEIGHT- See Also:
-
TEXT_WIDTH
public static final int TEXT_WIDTH- See Also:
-
TEXT_HEIGHT
public static final int TEXT_HEIGHT- See Also:
-
BACKGROUND_COLOR
-
BUTTON_CMD_OK
- See Also:
-
BUTTON_CMD_CANCEL
- See Also:
-
BUTTON_CMD_NEXT
- See Also:
-
BUTTON_CMD_BACK
- See Also:
-
BUTTON_CMD_FINISH
- See Also:
-
BUTTON_CMD_ADD
- See Also:
-
BUTTON_CMD_REMOVE
- See Also:
-
BUTTON_CMD_MOVEUP
- See Also:
-
BUTTON_CMD_MOVEDOWN
- See Also:
-
buttonPrefSize
-
buttconPrefSize
-
smbuttonPrefSize
-
labelPrefSize
-
textPrefSize
-
-
Constructor Details
-
CommonUI
public CommonUI()
-
-
Method Details
-
getTooltipPrefix
-
getTooltipPrefixInline
-
wrapInTitledPanel
-
createLabel
-
createLabel
-
createAccessoryButton
-
createToolbarButton
Returns a minimalized toolbar button with no text. The componentTestName parameter is used to set the component name for automated testing. It can be anything unique. -
createTextField
Creates a text field- Parameters:
text- Text for the fieldlistener- KeyListenernumbers- Indicates that this field represents numbers only
-
createTextField
-
createTextField
-
createTextField
-
createRadioButton
public static JRadioButton createRadioButton(String text, int mnemonic, ActionListener listener, boolean selected) Creates a Radio Button- Parameters:
text- Text to displaymnemonic- Hot keylistener- ActionListenerselected- Flag to indicate if button should be selected
-
createRadioButton
-
createRadioButton
-
createRadioButton
-
createRadioButton
-
initButtonGroup
-
createCheckBox
public static JCheckBox createCheckBox(String text, int mnemonic, ActionListener listener, boolean selected) Create a checkbox- Parameters:
text- to displaymnemonic- Hot keylistener- ActionListenerselected- Flag to indicate if button should be selected
-
createCheckBox
-
createCheckBox
-
createCheckBox
-
createCheckBox
-
createComboBox
Creates a JComboBox- Parameters:
items- Object arraylistener- The action listener which handles eventseditable- Flag that indicates if this combo box is editable
-
createComboBox
-
createButton
Creates a JButton- Parameters:
text- to displaylistener- The action listener which handles eventsmnemonic- Letter combination
-
createButton
public static JButton createButton(String text, ActionListener listener, String mnemonic, String actionCommand) -
createButton
-
createSmallButton
Creates a Smaller JButton- Parameters:
text- to displaylistener- The action listener which handles eventsmnemonic- Letter combination
-
createSmallButton
-
createBorder
-
createBorder
Creates an blank border with the displayed text -
createListPane
Wraps a scrollpane with and etched border and a title around a JList.- Parameters:
list- JList to wrap.text- Text to display in the border.
-
centerComponent
-
centerComponent
Centers the Component on the screen. -
sizeAndCenterOnDisplay
Sizes a window to at most the usable area of the display it is on, and centers it there.For a window whose preferred size can exceed the display it opens on.
centerComponent(Component)centers against the whole primary screen and doesn't bound the size at all, so an oversized window ends up with its top and bottom pushed off-screen. Note that this bounds rather than fits: a window taller than the display still has to find the height from somewhere of its own, typically by scrolling.Both the size and the location come from the same rectangle. Clamping against the usable area while centering against the whole screen would offset the window by half the difference between them — which is exactly the reserved strip it is meant to stay clear of.
- Returns:
- the size actually applied, which the caller may need if it re-applies the size later
-
usableBounds
The usable area of the display the given window is on: that display's bounds, less the strips the OS reserves for a taskbar, Dock or menu bar.Deliberately not
GraphicsEnvironment.getMaximumWindowBounds(), which answers for the primary display however many are attached — a window on a secondary display would be measured by the dimensions of a display it isn't on, either overflowing a smaller one or being clamped needlessly on a larger one. -
setupCancelButton
Sets up the ESC-key binding for a cancel button -
getParentFrame
-
msToSec
-
secToMs
-
stringFromStringArray
-
stringFromStringArray
-
stringArrayFromString
-
stringArrayFromString
-
setWaitCursor
-
setDefaultCursor
-
setDropCursor
-
adjustPopupLocationToFitScreen
public static Point adjustPopupLocationToFitScreen(int xposition, int yposition, JComponent component, Component invoker) Adjusts a desired popup location to fit within the screen, given the component's preferred size. Implementation copied from JPopupMenu. -
eventModifiersToString
-