Package ucar.unidata.util
Class GuiUtils
java.lang.Object
ucar.unidata.util.MenuUtil
ucar.unidata.util.LayoutUtil
ucar.unidata.util.GuiUtils
This is a vast catchall class to old various
utilities for doing GUI things.
- Author:
- IDV development team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class CardLayoutPanel is a utility that does a card layou of its components.static class
A color swatch panelstatic class
static class
Class ProgressDialog _more_static class
Class TreeSearchResults Holds state from a tree searchstatic class
Class for a vertical label -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic final String
xml attribute namestatic Font
Used by apps for having a common font for buttonsstatic String
Action command used for the Apply buttonstatic String
Action command used for the Cancel buttonstatic String
Action command used for the Close buttonstatic String
Action command used for the Export buttonstatic String
Action command used for the Help buttonstatic String
Action command used for the Import buttonstatic String
Action command used for the New buttonstatic String
Action command used for the No buttonstatic String
Action command used for the OK buttonstatic String
Action command used for the Open buttonstatic String
Action command used for the Remove buttonstatic String
Action command used for the Rename buttonstatic String
Action command used for the Reset buttonstatic String
Action command used for the Save buttonstatic String
Action command used for the Saveas buttonstatic String
Action command used for the Start buttonstatic String
Action command used for the Stop buttonstatic String
Action command used for the Submit buttonstatic String
Action command used for the Update buttonstatic String
Action command used for the Yes buttonstatic final String[]
Used to map named colors to colorstatic final Color[]
Used to map named colors to colorstatic final int[]
font sizesstatic final String
hex color string without leading #static String
missing image pathstatic final Cursor
The normal cursor_static final TimeZone
_more_static final Cursor
The cursor to use when waitingFields inherited from class ucar.unidata.util.LayoutUtil
INSETS_2, INSETS_5, tmpAnchor, tmpColFills, tmpFill, tmpInsets, WT_N, WT_NN, WT_NNN, WT_NNNY, WT_NNY, WT_NNYN, WT_NNYNY, WT_NNYNYNY, WT_NY, WT_NYN, WT_NYNY, WT_NYNYN, WT_NYY, WT_Y, WT_YN, WT_YNN, WT_YNY, WT_YNYN, WT_YY, WT_YYN, WT_YYY, ZERO_INSETS
Fields inherited from class ucar.unidata.util.MenuUtil
MENU_SEPARATOR
-
Method Summary
Modifier and TypeMethodDescriptionstatic JComponent
addActionListener
(JComponent comp, Object object, String methodName, Object arg) Adds an action listener to the button.static void
addKeyBindings
(JTextComponent comp) _more_static void
addKeyListenerRecurse
(KeyListener listener, Container c) Add a key listener to all components of a containerstatic void
addLinkListener
(JEditorPane editor) _more_static void
Add the model dialog to the liststatic void
addMouseListenerRecurse
(MouseListener listener, Container c) Add a mouse listener to all components of a containerstatic boolean
anySelected
(JComboBox box) Check if there are any selected items in the combobox.static void
appendText
(JTextComponent fld, String s, String delimiter) _more_static void
applyDefaultFont
(Component comp) _more_static boolean
askOkCancel
(String title, Object question) Ask the user the question.static boolean
Ask the user the question.static ButtonGroup
buttonGroup
(JToggleButton b1, JToggleButton b2) Create a button group and add the two buttons to it.static ButtonGroup
buttonGroup
(JToggleButton b1, JToggleButton b2, JToggleButton b3) Create a button group and add the three buttons to it.static ButtonGroup
buttonGroup
(JToggleButton b1, JToggleButton b2, JToggleButton b3, JToggleButton b4) Create a button group and add the three buttons to it.static int
charToKeyCode
(char ch) Return the numeric key code of the given character.static int
Take the first character of the string and return the numeric key codestatic void
Walk the components of the tab and toggle the heavyweight components visiblitystatic boolean
checkHeight
(int height) Check the height against a valuestatic JLabel
Create a center aligned JLabelstatic void
configureStepSelection
(JList list) Add a listener to the JList that pops up a menu on a right click that allos for the selection of different strides.static JDialog
createDialog
(Window parent, String title, boolean modal) Utility to create a JDialog with a parent component.static JDialog
createDialog
(String title, boolean modal) A utility to create a dialog.static JFrame
createFrame
(String title) A utility to create a frame.static JComboBox
createValueBox
(ActionListener listener, String command, int initValue, List values, boolean editable) Create a combobx boxc that holds a set of integer values.static Color
decodeColor
(String value, Color dflt) This takes the given String and tries to convert it to a color.static void
decorateFrame
(JFrame frame, JMenuBar menuBar) _more_static double
distance
(double[] p1, double[] p2) Get distance betweenstatic double
distance
(double x1, double y1, double x2, double y2) Calculate distance between 2 points.static double
distance
(double x, double y, Rectangle2D r) Calculate distance between point and rectangle.static double
distance
(int[] p1, int[] p2) Get distance betweenstatic boolean
_more_static JComboBox
Make a font selector boxstatic JComboBox
doMakeFontSizeBox
(int size) Make a box for setting the font sizestatic JComponent
doMultiSplitPane
(List comps, boolean hsplit) Make an evenly balanced group of split panes for the given componentsstatic GuiUtils.TreeSearchResults
doTreeSearch
(JTree tree, Object lastState, String nodeDesc, JComponent near) Popup a dialog and search the given tree for a tree node that matches the user provided string.static GuiUtils.TreeSearchResults
doTreeSearch
(JTree tree, Object lastState, String nodeDesc, JComponent near, String originalPhrase) Search the given treestatic void
If non-null then removes all children and removes from parent.static void
If non-null then removes all children and removes from parent.static void
enableComponents
(List comps, boolean enable) Enable or disable the list of Componentsstatic void
enablePanel
(JPanel panel, boolean enable) _more_static void
enableTree
(Component comp, boolean enable) Enable or disable a whole tree's worth of componentsstatic void
expandPathsAfterChange
(JTree tree, Hashtable state, DefaultMutableTreeNode root) Call this after the structure of a JTree changes to re-expand the paths.static void
exportAsCsv
(String header, TableModel model) Write out the given table model as a comma separated value (CSV) file prepending the header.static void
exportAsCsv
(String header, TableModel model, boolean includeColumnNames) Write out the given table model as a comma separated value (CSV) file prepending the header.static void
exportAsCsv
(String header, TableModel model, String filename) Export a table as csvstatic void
exportAsCsv
(String header, TableModel model, String filename, boolean includeColumnNames) Export a table as csvstatic void
exportAsCsv
(TableModel model) Write out the given table model as a csv filestatic List
findChildren
(Node parent, String tag) _more_static JPanel
Create a panel and do flow layout of the componentsstatic JPanel
Create a panel and do a a right align flow layout of the componentsstatic String
formatDate
(Date dttm) Format the date with the default date format and timezonestatic JComponent
formLayout
(Component[] comps) Do a 2 column layout.static JComponent
formLayout
(Component[] comps, double[] widths, double[] heights) Do a 2 column layout.static JComponent
formLayout
(Object[] objects) This does a doLayout with 2 columns.static JComponent
formLayout
(Object[] objects, Insets insets) This does a doLayout with 2 columns.static JComponent
formLayout
(List objects) Layout as a 2 column formstatic JComponent
formLayout
(List comps, boolean rightAlignFirstColumn) Do a 2 column layout.static JComponent
formLayout
(List comps, double[] widths, double[] heights) Do a 2 column layout.static JComponent
formLayout
(List comps, double[] widths, double[] heights, boolean rightAlignFirstColumn) Do a 2 column layout.static JComponent
formLayout
(List objects, Insets insets) Do a 2 column layout of the objects with the given insets for spacingstatic String
_more_static String
getAttribute
(NamedNodeMap attrs, String name) _more_static boolean
getAttribute
(NamedNodeMap attrs, String name, boolean dflt) _more_static String
getAttribute
(NamedNodeMap attrs, String name, String dflt) _more_static String
getAttribute
(Node element, String name, String dflt) Get the given name-d attribute from the given element.static int
getBoxValue
(JComboBox box) Return the selected item in the given box as an integer.static ObjectListener
getCloseDialogListener
(JDialog dialog) Create a listener that will close the given dialog.static String
getColorName
(Color color) Return the name of the given color.static void
getConfigureStepSelectionItems
(JList list, List items) popup a menu to select stridesstatic Font
Get the default fontstatic int
Get the default icon sizestatic JComboBox
getEditableBox
(List items, Object selected) Create an editable combobox with the given items.static JLabel
Create a JLabel with a fixed width fontstatic Vector
Get a list of fontsstatic Vector
Get a list of font sizesstatic JFrame
This finds and returns the JFrame, or null if not found, that holds the given component.static Component[]
getHtmlComponent
(String html, HyperlinkListener linkListener, int width, int height) Make a JTextEditor component and scroller for the given htmlstatic boolean
Do we show icons in the menusstatic Image
Get the screen image from the componentstatic Image
Create an Image from the given image file name.static Image
Create an Image from the given image file name.static Image
Create an Image from the given image file name.static Image
Get an imagestatic JButton
getImageButton
(String icon, Class origin) Create a JButton that displays an image icon create from the given icon path (may be a file, resource or url).static JButton
getImageButton
(String icon, Class origin, int hInset, int vInset) Create a JButton that displays an image icon create from the given icon path (may be a file, resource or url).static JButton
getImageButton
(ImageIcon icon) Create a JButton that displays the given image iconstatic JButton
getImageButton
(ImageIcon icon, int offset) Create a JButton that displays the given image iconstatic JButton
getImageButton
(ImageIcon icon, int hinset, int vinset) Create a JButton that displays the given image iconstatic ImageIcon
getImageIcon
(String file) Create an ImageIcon from the given image file name.static ImageIcon
getImageIcon
(String file, boolean cache) Create an ImageIcon from the given image file name.static ImageIcon
getImageIcon
(String file, Class c) Create an ImageIcon from the given image file name.static ImageIcon
getImageIcon
(String file, Class c, boolean cache) Create an ImageIcon from the given image file name.static JLabel
getImageLabel
(String icon) Create a JLabel that displays an image icon create from the given icon path (may be a file, resource or url).static JLabel
getImageLabel
(String icon, Class origin) Create a JLabel that displays an image icon create from the given icon path (may be a file, resource or url).static String
Ask the user the question.static String
Ask the user the question.static String
Ask the user the question.static String
Ask the user the question.static String
getInput
(String question, String label, String initValue, String trailingLabel, Object underLabel, String title) Ask the user the question.static String
getInput
(String question, String label, String initValue, String trailingLabel, Object underLabel, String title, int fieldWidth) Ask the user the question.static String
getInput
(String question, String label, String initValue, String trailingLabel, Object underLabel, String title, int fieldWidth, JComponent nearComponent) Ask the user the question.static int
getInt
(JTextField fld) Get an integer value from the text fieldstatic List
return the list of items held by the combo box.static List
_more_static String
getLocalName
(String n, boolean local) _more_static String
getLocalName
(String n, boolean local, boolean addHtml) _more_static Point
getLocation
(Component src) Find the location of the given componet on the screen.static JTabbedPane
Make a JTabbedPane without some of its borderstatic JTabbedPane
getNestedTabbedPane
(int orient) Make a JTabbedPane without some of its borderstatic JTabbedPane
getNestedTabbedPane
(int orient, int top, int left, int bottom, int right) Make a JTabbedPane without some of its borderstatic JButton
getScaledImageButton
(String icon, Class origin, int hInset, int vInset) Get a scaled image buttonstatic ImageIcon
getScaledImageIcon
(String file, Class c, boolean cache) Get a scaled image iconstatic double
Return the slider value as a percentage between its min and maxstatic TimeZone
Get the default timezone used for formattingstatic JToggleButton
getToggleButton
(String iconPath, int hinset, int vinset) Create a toggle button with the given image.static JToggleButton
getToggleButton
(ImageIcon icon, int hinset, int vinset) Create a toggle button with the given image.static JToggleButton
getToggleImageButton
(String icon, String selectedIcon, int hinset, int vinset, boolean addMouseOverBorder) Create a JToggleButton with the given image and, if non-null, the given selected image.static JToggleButton
getToggleImageButton
(ImageIcon icon, ImageIcon selectedIcon, int hinset, int vinset) Create a JToggleButton with the given image and, if non-null, the given selected image.static JToggleButton
getToggleImageButton
(ImageIcon icon, ImageIcon selectedIcon, int hinset, int vinset, boolean addMouseOverBorder) Create a JToggleButton with the given image and, if non-null, the given selected image.static double
getValue
(JTextField fld) Get an double value from the text fieldstatic int
getValueFromBox
(JComboBox box) Get the integer value from a JComboBox of integer itemsstatic Window
This finds and returns the Window, or null if not found, that contains the given component.static void
Add a change listener to the tab that toggles on any heavy weight components in the selected tab and turns off any in the non-selected tabs.static JComponent
hspace
(int w, int h) Create a a minimally sized spacerstatic JSplitPane
Create a basic horizontally aligned JSplitPanestatic JSplitPane
Create a horizontally aligned JSplitPanestatic JSplitPane
Create a horizontally aligned JSplitPanestatic JSplitPane
Create a horizontally aligned JSplitPane.static Hashtable
Call this before a JTree changes.static void
Init the fixed labelsstatic void
insertText
(JTextComponent comp, String s) Insert text into the componentstatic void
invokeInSwingThread
(Runnable runnable) RUn the given runnable in the swing event dispatch threadstatic boolean
isControlKey
(InputEvent event) Is the given event a control (or meta for the mac) keystatic boolean
isControlKey
(KeyEvent event, int keyCode) _more_static boolean
_more_static boolean
isMac()
Is this running on a Mac?static boolean
Is the dialog showingstatic boolean
Is the frame showingstatic Component
italicizeFont
(Component comp) Italicize the font on the given componentstatic JPanel
Create a JPanel that holds a the given widget/JLabelstatic JPanel
Create a JPanel that holds a JLabel/the given widgetstatic void
limitMenuSize
(List items, String name, int size) This takes the list of JMenuItems and, for each JMenu, will ensure that there are no more than size number of items in any sub menu.static void
limitMenuSize
(JMenu menu, String name, int size) This ensures that there are no more than size number of items in any sub menu.static void
limitMenuSize
(JMenu menu, String name, int size, boolean recurse) This ensures that there are no more than size number of items in any sub menu.static JLabel
Create a left aligned JLabelstatic void
teststatic ActionListener
makeActionListener
(Object object, String methodName, Object arg) Make an ActionListener.static JButton
Utility to make apply button panelstatic JPanel
Utility to make apply/cancel button panelstatic JPanel
Utility to make apply/ok/cancel button panelstatic JPanel
Utility to make apply/ok/help/cancel button panelstatic JPanel
Utility to make apply/ok/reset/cancel button panelstatic JButton
makeButton
(String label, Object object, String methodName) Make a JButton.static JButton
makeButton
(String label, Object object, String methodName, Object arg) Make a JButton.static JButton
Make a JButton.static JPanel
makeButtons
(ActionListener l, String[] cmds) Make a set of JButtons, each with a label and action command from the given cmds array.static JPanel
makeButtons
(ActionListener l, String[] labels, String[] cmds) Make a set of JButtons, each with a label and action command from the given cmds and labels arrays.static JPanel
makeButtons
(ActionListener l, String[] labels, String[] cmds, String[] tooltips, Hashtable buttonMap) Make a set of JButtons, each with a label and action command from the given cmds and labels arrays.static JPanel
makeButtons
(ActionListener l, String[] labels, String[] cmds, Hashtable buttonMap) Make a set of JButtons, each with a label and action command from the given cmds and labels arrays.static JPanel
makeButtons
(ActionListener l, String[] cmds, Hashtable buttonMap) Make a set of JButtons, each with a label and action command from the given cmds array.static JCheckBox
makeCheckbox
(String label, Object object, String property) Make a checkbox.static JCheckBox
makeCheckbox
(String label, Object object, String property, Object arg) Make a checkbox.static JComboBox
makeColorNameComboBox
(Color dflt) A helper to make a color selector combo boxstatic JComponent[]
makeColorSwatchWidget
(Color color, String label) This makes a color swatch and a 'Set' button that is used to set the color.static JComboBox
makeComboBox
(int[] values, String[] labels, int current) Make a combo box from a set of values and labelsstatic JComboBox
makeComboBox
(List items, Object selected, boolean editable, Object listener, String methodName) Make a JComboBoxstatic JComboBox
makeComboBox
(List items, Object selected, boolean editable, Object listener, String methodName, boolean inAThread) Make a JComboBoxstatic int
Make and show a modeful dialog with the given collection of buttons.static JMenu
makeDynamicMenu
(String name, Object object, String methodName) Create a menu and add a listener to it that removes all items and calls the given method on te given object with the menu as an argument.static JMenu
makeDynamicMenu
(String name, Object object, String methodName, boolean doRemoveAll) Create a menu and add a listener to it that removes all items and calls the given method on te given object with the menu as an argument.static JButton
Make a button that pops up a file browser and sets the text of the given field with the selected filestatic JButton
makeFileBrowseButton
(JTextComponent fld, boolean chooseDirectory, List filters) Make a button that pops up a file browser and sets the text of the given field with the selected filestatic JButton
makeFileBrowseButton
(JTextComponent fld, List filters) Make a button that pops up a file browser and sets the text of the given field with the selected filestatic JComponent
makeHeader
(String label) Utility to create a header that is a label and a line.static JButton
makeImageButton
(String label, Object object, String methodName) Make a JButton.static JButton
makeImageButton
(String label, Object object, String methodName, Object arg) Make a JButton.static JButton
makeImageButton
(String label, Object object, String methodName, Object arg, boolean addMouseOverBorder) Make a JButton.static JButton
makeJButton
(String label, ActionListener listener) Utility to make a JButton, adding the given listener as an ActionListenerstatic JButton
makeJButton
(String label, Object[] args) Utility method for creating and setting various properties of a JButton args array holds a set of key value pairs: -tooltip <The tooltip text> -bg <Background color> -listener <Action listener> -command <Action command>static JMenuBar
makeMenuBar
(List menus) Create a JMenuBar and add the menus contained with the menus list If no menus then return null.static void
Make a mouse over borderstatic JPanel
Utility to make new/ok/cancel button panelstatic JPanel
makeNewOkCancelButtons
(ActionListener l, String newLabel, String okLabel, String cancelLabel) Utility to make new/ok/cancel button panelstatic JPanel
Utility to make new/ok/cancel/help button panelstatic JPanel
Utility to make ok/cancel button panelstatic JPanel
makeOkCancelButtons
(ActionListener l, String okLabel, String cancelLabel) Utility to make ok/cancel button panelstatic JPanel
Utility to make ok/help/cancel button panelstatic JRadioButton[]
makeRadioButtons
(List labels, int selectedIndex, Object object, String methodName) Make a set of radio buttonsstatic void
makeRowVisible
(JTable table, int row) Make the given row in the table visiblestatic JScrollPane
makeScrollPane
(Component c, int xdim, int ydim) Make a scroll pane for the input box which may be used to hold selection buttons later; size is given; text for a title in box.static JSlider
makeSlider
(int min, int max, int value, Object listener, String methodName) Make a JSliderstatic JSlider
makeSlider
(int min, int max, int value, Object listener, String methodName, boolean updateAsMove) Make a JSliderstatic JComponent[]
makeSliderPopup
(int min, int max, int value, ChangeListener listener) This creates a JButton and a JSlider.static TwoFacedObject
Make a TwoFacedObject from a font for displaying in a combobox.static JLabel
makeVerticalLabel
(String text) Make a vertical labelstatic JFrame
makeWindow
(String title, Component contents, int x, int y) Create a new JFrame, add the contents to it, set its location and return it.static void
_more_static JDialog
packDialog
(JDialog f, Component contents) Add the given contents into the given dialogstatic void
packInCenter
(JDialog dialog) pack the dialog in the center of the screenstatic JFrame
packWindow
(JFrame f, Component contents) Add the given contents into the given framestatic JFrame
packWindow
(JFrame f, Component contents, boolean andShow) Add the given contents into the given framestatic Component[]
Popup an html widget at the given x/y that shows the text (or, if the text is a URI will read the URI).static void
popupUnitMenu
(JTextField fld, JComponent comp) This pops up a menu near the given comp and allows the user to select a unit name which gets put into the given fldstatic void
positionAndFitToScreen
(Window window, Rectangle bounds) Position and fit a window to the screenstatic JMenu
processXmlMenu
(Node menuNode, ActionListener listener, Hashtable menuItems) Create the JMenu from the given xml.static JMenu
processXmlMenu
(Node menuNode, ActionListener listener, Hashtable menuItems, Hashtable<String, ImageIcon> actionIcons) Create the JMenu from the given xml.static JMenuBar
processXmlMenuBar
(Element root, JMenuBar menuBar, ActionListener listener, Hashtable menuItems) Create, if null, and ddd to the JMenuBar from the xmlstatic JMenuBar
processXmlMenuBar
(Element root, JMenuBar menuBar, ActionListener listener, Hashtable menuItems, Hashtable<String, ImageIcon> actionIcons) Create, if null, and ddd to the JMenuBar from the xmlstatic JMenuItem
processXmlMenuItem
(Node node, ActionListener listener, Hashtable menuItems) Create the JMenuItem defined by the given xmlstatic JMenuItem
processXmlMenuItem
(Node node, ActionListener listener, Hashtable menuItems, Hashtable<String, ImageIcon> actionIcons) Create the JMenuItem defined by the given xmlstatic void
Remove the model dialog from the liststatic void
Walk the components of the tab and toggle the heavyweight components visiblitystatic JLabel
Create a right aligned JLabelstatic ImageIcon
scaleImageIcon
(ImageIcon icon) This scales the image icon up to the minimum icon size if it is definedstatic void
scrollToTop
(JEditorPane editor) Scroll the given component to the topstatic void
setApplicationTitle
(String title) _more_static void
setBackgroundOnTree
(Container c, Color bgColor) Recurse the Component hierarchy, setting the background color of each component.static void
This finds the Window the given component c is in and, if it is found, sets the cursor of the Window to the given cursor.static void
Set the default date formatstatic void
setDefaultFont
(Font font) Set the default fontstatic void
setDefaultIconSize
(int size) Set the default icon sizestatic void
setFixedWidthFont
(Component comp) Set the font on the component to be monospacedstatic void
setFontOnTree
(JComponent c, Font f) Recurse the Component hierarchy, setting the font.static void
setForegroundOnTree
(Component comp, Color fgColor) Recurse the Component hierarchy, setting the foreground color of each component.static void
setForegroundOnTree
(Component comp, Color fgColor, Color ifEquals) Recurse the Component hierarchy, setting the foreground color of each component.static AbstractButton
setIcon
(AbstractButton button, String iconPath) Set the icon on the button.static void
setIconsInMenus
(boolean doIcons) Do we show icons in the menusstatic void
setListData
(JComboBox box, Object[] items) Procedure to set the list of items in a ComboBoxstatic void
setListData
(JComboBox box, List items) Procedure to set the list of items in a ComboBoxstatic void
setPreferredWidth
(JComponent comp, int width) Set the preferred width on a componentstatic void
setSelectedItems
(JList list, List selected) _more_static JComponent
setSize
(JComponent comp, int w, int h) Set the size and preferred size of the component and return itstatic void
setSliderPercent
(JSlider s, double percent) Set the slider value as a percentage between its min and maxstatic void
setTimeZone
(TimeZone tz) Set the default timezone used for formattingstatic void
setToolTipOnTree
(Container c, String tooltip) Recurse the Component hierarchy, setting the tooltip of each component.static void
setupDirectoryChooser
(JButton btn, JTextField directoryFld) Set up a directory chooserstatic void
setupFileChooser
(JButton btn, JTextField directoryFld, boolean justDirectories) Set up a directory chooserstatic void
setValueOfBox
(JComboBox box, int value, int[] values, String[] labels) Set the value of the boxstatic void
showComponentInTabs
(Component comp) Show the component in any contained tabsstatic void
showComponentInTabs
(Component comp, boolean andShowWindow) Show the component in any containing tabsstatic void
showDialog
(String title, Component comp) Show the given component in a dialog.static void
showDialog
(String title, Component comp, Component parentComponent) Show the given component in a dialog.static void
showDialogNearSrc
(Component src, Component theWindow) This will set the location of the theWindow component (might be A JDialog or a JFrame) at the screen location of the given src component.static void
showFrameAsDialog
(Component parentComponent, JFrame frame) popup but a modal dialog with input Jframestatic Component[]
showHtmlDialog
(String html, String title, String label, HyperlinkListener linkListener, boolean modal) Show a dialog window that contains an html editorstatic Component[]
showHtmlDialog
(String html, String title, HyperlinkListener linkListener) Show the given html in a window with the given title.static Component[]
showHtmlDialog
(String html, HyperlinkListener linkListener) Show the given html in a window.static void
showInCenter
(JDialog dialog) pack and show the dialog in the center of the screenstatic void
Show the list interval selection dialogstatic boolean
showOkCancelDialog
(Window f, String title, Component contents, Component src) Show a modeful Ok/Cancel dialog.static boolean
showOkCancelDialog
(Window f, String title, Component contents, Component src, List actionComponents) Show a modeful Ok/Cancel dialog.static boolean
showOkCancelDialog
(Window f, String title, Component contents, Component src, List actionComponents, String okLabel) Show a modeful Ok/Cancel dialog.static boolean
showOkCancelDialog
(Window f, String title, Component contents, Component src, List actionComponents, String okLabel, boolean resizable, Dimension dialogPrefSize) Show a modal Ok/Cancel dialog.static void
showOkDialog
(Window f, String title, Component contents, Component src) Show OK dialogstatic void
_more_static void
This will show and/or deiconify the given component.static int
showYesNoCancelDialog
(Window frame, String message, String title) Show a modeful dialog, attached to the given frame, with the given message.static int
showYesNoCancelDialog
(Window frame, String message, String title, String defaultCmd) Show a modeful dialog, attached to the given frame, with the given message.static boolean
showYesNoDialog
(Window frame, String title, Component contents, Component src) Show a modeful dialog, attached to the given frame, with the given message.static boolean
showYesNoDialog
(Window frame, String message, String title) Show a modeful dialog, attached to the given frame, with the given message.static boolean
Show a modeful dialog, attached to the given frame, with the given message.static String
toCsv
(TableModel model) Convert the given table model to comma separated stringstatic String
toCsv
(TableModel model, boolean includeColumnNames) Convert the given table model to comma separated stringstatic void
Move the window to the frontstatic void
Move to the front any modal dialogsstatic void
toggleHeavyWeightComponents
(Component comp, boolean visible) Walk the tree and set any heavyweight components visibility.static JComponent
This makes a component that contains a jlabel.static JSplitPane
Create a JSplitPane in vertical mode.static JSplitPane
Create a JSplitPane in vertical mode.static JSplitPane
Create a JSplitPane in vertical mode.static JSplitPane
Create a JSplitPane in vertical mode.Methods inherited from class ucar.unidata.util.LayoutUtil
bottom, center, centerBottom, centerRight, colGrid, doLayout, doLayout, doLayout, doLayout, doLayout, filler, filler, getComponentArray, grid, grid, hbox, hbox, hbox, hbox, hbox, hbox, hbox, hbox, hbox, hbox, hbox, hfill, hflow, hflow, hgrid, hgrid, hgrid, inset, inset, inset, inset, left, leftCenter, leftCenterRight, leftRight, leftVbox, right, rowGrid, rowGrid, setAnchorBottom, setAnchorTop, setHFill, setNoFill, toList, top, topBottom, topCenter, topCenterBottom, topLeft, vbox, vbox, vbox, vbox, vbox, vbox, vbox, vgrid, vgrid, wrap, wrapLeft
Methods inherited from class ucar.unidata.util.MenuUtil
findMethod, makeCheckboxMenuItem, makeCheckboxMenuItem, makeMenu, makeMenu, makeMenuItem, makeMenuItem, makeMenuItem, makeMenuItems, makePopupMenu, makePopupMenu, showPopupMenu, typesMatch
-
Field Details
-
MISSING_IMAGE
missing image path -
ATTR_ACTION
xml attribute name- See Also:
-
ATTR_TOOLTIP
xml attribute name- See Also:
-
ATTR_ICON
xml attribute name- See Also:
-
ATTR_ID
xml attribute name- See Also:
-
waitCursor
The cursor to use when waiting -
normalCursor
The normal cursor_ -
FONT_SIZES
public static final int[] FONT_SIZESfont sizes -
COLORNAMES
Used to map named colors to color -
COLORS
Used to map named colors to color -
HEX_COLOR_PATTERN
hex color string without leading #- See Also:
-
CMD_APPLY
Action command used for the Apply button -
CMD_CANCEL
Action command used for the Cancel button -
CMD_CLOSE
Action command used for the Close button -
CMD_IMPORT
Action command used for the Import button -
CMD_EXPORT
Action command used for the Export button -
CMD_SUBMIT
Action command used for the Submit button -
CMD_RENAME
Action command used for the Rename button -
CMD_REMOVE
Action command used for the Remove button -
CMD_NEW
Action command used for the New button -
CMD_YES
Action command used for the Yes button -
CMD_NO
Action command used for the No button -
CMD_OK
Action command used for the OK button -
CMD_OPEN
Action command used for the Open button -
CMD_RESET
Action command used for the Reset button -
CMD_HELP
Action command used for the Help button -
CMD_SAVE
Action command used for the Save button -
CMD_SAVEAS
Action command used for the Saveas button -
CMD_UPDATE
Action command used for the Update button -
CMD_START
Action command used for the Start button -
CMD_STOP
Action command used for the Stop button -
buttonFont
Used by apps for having a common font for buttons -
TIMEZONE_UTC
_more_
-
-
Method Details
-
initLabels
public static void initLabels()Init the fixed labels -
setTimeZone
Set the default timezone used for formatting- Parameters:
tz
- timezone
-
getTimeZone
Get the default timezone used for formatting- Returns:
- timezone
-
setDefaultDateFormat
Set the default date format- Parameters:
fmt
- date format string
-
formatDate
Format the date with the default date format and timezone- Parameters:
dttm
- date- Returns:
- formatted date
-
setDefaultIconSize
public static void setDefaultIconSize(int size) Set the default icon size- Parameters:
size
- new size
-
getDefaultIconSize
public static int getDefaultIconSize()Get the default icon size- Returns:
- the default icon size
-
setDefaultFont
Set the default font- Parameters:
font
- the default font
-
getDefaultFont
Get the default font- Returns:
- the default font
-
applyDefaultFont
_more_- Parameters:
comp
- _more_
-
getFixedWidthLabel
Create a JLabel with a fixed width font- Parameters:
s
- Initial label string- Returns:
- label
-
setFixedWidthFont
Set the font on the component to be monospaced- Parameters:
comp
- The component
-
setCursor
This finds the Window the given component c is in and, if it is found, sets the cursor of the Window to the given cursor.- Parameters:
component
- The component to look for the window fromcursor
- The cursor
-
getFrame
This finds and returns the JFrame, or null if not found, that holds the given component.- Parameters:
component
- The component to look for the frame- Returns:
- The JFrame
-
showComponentInTabs
Show the component in any contained tabs- Parameters:
comp
- The component to look for the window from
-
showComponentInTabs
Show the component in any containing tabs- Parameters:
comp
- Component to showandShowWindow
- If we get to a window do we also show it
-
toFront
Move the window to the front- Parameters:
window
- the window
-
getWindow
This finds and returns the Window, or null if not found, that contains the given component.- Parameters:
component
- The component to look for the window from- Returns:
- The window the component is on or null if not found
-
empty
If non-null then removes all children and removes from parent.- Parameters:
c
- The component to empty
-
empty
If non-null then removes all children and removes from parent.- Parameters:
c
- The component to emptydoItInSwingThread
- If true then do the emptying in the Swing thread
-
decodeColor
This takes the given String and tries to convert it to a color. The string may be a space or comma separated triple of RGB integer values. It may be an integer or it may be a color name defined in the COLORNAMES array- Parameters:
value
- String valuedflt
- This is returned if the value cannot be converted- Returns:
- Color defined by the String value or the dflt
-
getColorName
Return the name of the given color.- Parameters:
color
- The color- Returns:
- name of the color
-
checkHeight
public static boolean checkHeight(int height) Check the height against a value- Parameters:
height
- the value to check- Returns:
- return height > 100;
-
setPreferredWidth
Set the preferred width on a component- Parameters:
comp
- componentwidth
- width
-
makeColorSwatchWidget
This makes a color swatch and a 'Set' button that is used to set the color. It returns a 2 element array holding the swatch and the button.- Parameters:
color
- The initial colorlabel
- The label to use when popping up the color dialog- Returns:
- 3 element array that holds the swatch and the set button and the clear button
-
makeColorNameComboBox
A helper to make a color selector combo box- Parameters:
dflt
- The default color value- Returns:
- The color selector combo box
-
getImageIcon
Create an ImageIcon from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image file- Returns:
- The ImageIcon or null if it could not be created
-
getImageIcon
Create an ImageIcon from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image filecache
- Should the local in memory cache be checked- Returns:
- The ImageIcon or null if it could not be created
-
getImageIcon
Create an ImageIcon from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image filec
- The class to use when looking up the image as a resource- Returns:
- The ImageIcon or null if it could not be created
-
getImageIcon
Create an ImageIcon from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image filec
- The class to use when looking up the image as a resourcecache
- Should the local in memory cache be checked- Returns:
- The ImageIcon or null if it could not be created
-
getScaledImageIcon
Get a scaled image icon- Parameters:
file
- location of the imagec
- relative classcache
- true to cache result- Returns:
- the icon or null
-
scaleImageIcon
This scales the image icon up to the minimum icon size if it is defined- Parameters:
icon
- The icon- Returns:
- The scaled icon
-
getImage
Create an Image from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image file- Returns:
- The Image or null if it could not be created
-
getImage
Create an Image from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image filec
- Used to lookup the image as a java resource- Returns:
- The Image or null if it could not be created
-
getImage
Create an Image from the given image file name. The filename may be a file, a java resource or a url.- Parameters:
file
- The image filec
- Used to lookup the image as a java resourcecache
- Should the local cache of Images be checked- Returns:
- The Image or null if it could not be created
-
getImage
Get an image- Parameters:
file
- location of the imagec
- relative classcache
- true to cache resultreturnNullIfNotFound
- true to return null;- Returns:
- image or null (if returnNullIfNotFound is true);
-
showDialogNearSrc
This will set the location of the theWindow component (might be A JDialog or a JFrame) at the screen location of the given src component. It will then show the theWindow.- Parameters:
src
- Where we locatetheWindow
- What we locate
-
showWidget
This will show and/or deiconify the given component. The component needs to be a Window or a Frame- Parameters:
c
- The thing to show.
-
makeJButton
Utility to make a JButton, adding the given listener as an ActionListener- Parameters:
label
- The button labellistener
- The ActionListener- Returns:
- The newly created button
-
makeJButton
Utility method for creating and setting various properties of a JButton args array holds a set of key value pairs: -tooltip <The tooltip text> -bg <Background color> -listener <Action listener> -command <Action command>- Parameters:
label
- The button labelargs
- The argname/value array- Returns:
- The newly created button
-
getSliderPercent
Return the slider value as a percentage between its min and max- Parameters:
s
- The slider- Returns:
- The percent value
-
setSliderPercent
Set the slider value as a percentage between its min and max- Parameters:
s
- The sliderpercent
- The percent value
-
setBackgroundOnTree
Recurse the Component hierarchy, setting the background color of each component.- Parameters:
c
- The componentbgColor
- The color
-
setToolTipOnTree
Recurse the Component hierarchy, setting the tooltip of each component.- Parameters:
c
- The componenttooltip
- The tooltip
-
setFontOnTree
Recurse the Component hierarchy, setting the font.- Parameters:
c
- The componentf
- The font
-
setForegroundOnTree
Recurse the Component hierarchy, setting the foreground color of each component.- Parameters:
comp
- The componentfgColor
- The color
-
setForegroundOnTree
Recurse the Component hierarchy, setting the foreground color of each component.- Parameters:
comp
- The componentfgColor
- The colorifEquals
- If non null then only set the foreground color on the component its current color equals the given fgColor
-
enableTree
Enable or disable a whole tree's worth of components- Parameters:
comp
- The componentenable
- The enable flag
-
enableComponents
Enable or disable the list of Components- Parameters:
comps
- List of componentsenable
- Enable or disable
-
enablePanel
_more_- Parameters:
panel
- _more_enable
- _more_
-
makeScrollPane
Make a scroll pane for the input box which may be used to hold selection buttons later; size is given; text for a title in box.- Parameters:
c
- The component to put in the scroll panexdim
- The x dimensionydim
- The y dimension- Returns:
- The new scroll pane
-
setSize
Set the size and preferred size of the component and return it- Parameters:
comp
- componentw
- widthh
- height_- Returns:
- The component
-
buttonGroup
Create a button group and add the two buttons to it.- Parameters:
b1
- Button 1b2
- Button 2- Returns:
- The created button group.
-
buttonGroup
Create a button group and add the three buttons to it.- Parameters:
b1
- Button 1b2
- Button 2b3
- Button 3- Returns:
- The created button group.
-
buttonGroup
public static ButtonGroup buttonGroup(JToggleButton b1, JToggleButton b2, JToggleButton b3, JToggleButton b4) Create a button group and add the three buttons to it.- Parameters:
b1
- Button 1b2
- Button 2b3
- Button 3b4
- Button 3- Returns:
- The created button group.
-
valignLabel
This makes a component that contains a jlabel. The jlabel is inset with some padding at the top and the outer component is aligned to the top. It is intended to be used when doing a form layout and the component on the right it a tall one- Parameters:
s
- The string to create the label with- Returns:
- the component
-
formLayout
Layout as a 2 column form- Parameters:
objects
- objects to lay out- Returns:
- the form
-
formLayout
Do a 2 column layout of the objects with the given insets for spacing- Parameters:
objects
- May be components or strings. If strings this method will create jlabelsinsets
- spacing- Returns:
- component
-
formLayout
This does a doLayout with 2 columns. If any of the objects are not a Component then it creates a rLabel(object.toString)- Parameters:
objects
- array of components to layoutinsets
- The spacing- Returns:
- component
-
formLayout
This does a doLayout with 2 columns. If any of the objects are not a Component then it creates a rLabel(object.toString)- Parameters:
objects
- array of components to layout- Returns:
- component
-
flowRight
Create a panel and do a a right align flow layout of the components- Parameters:
comps
- The components to add- Returns:
- The new panel
-
flow
Create a panel and do flow layout of the components- Parameters:
comps
- The components to add- Returns:
- The new panel
-
makeButtons
Make a set of JButtons, each with a label and action command from the given cmds array. Add the buttons into a new JPanel and return it.- Parameters:
l
- Listenercmds
- Button labels.action commands- Returns:
- JPanel that contains the buttons
-
makeButtons
Make a set of JButtons, each with a label and action command from the given cmds array. Add the buttons into a new JPanel and return it.- Parameters:
l
- Listenercmds
- Button labels.action commandsbuttonMap
- If non-null will hold a mapping from (String) command to JButton- Returns:
- JPanel that contains the buttons
-
makeButtons
Make a set of JButtons, each with a label and action command from the given cmds and labels arrays. Add the buttons into a new JPanel and return it.- Parameters:
l
- Listenerlabels
- Button labelscmds
- Button action commands- Returns:
- JPanel that contains the buttons
-
makeButtons
public static JPanel makeButtons(ActionListener l, String[] labels, String[] cmds, Hashtable buttonMap) Make a set of JButtons, each with a label and action command from the given cmds and labels arrays. Add the buttons into a new JPanel and return it.- Parameters:
l
- Listenerlabels
- Button labelscmds
- Button action commandsbuttonMap
- If non-null will hold a mapping from (String) command to JButton- Returns:
- JPanel that contains the buttons
-
makeButtons
public static JPanel makeButtons(ActionListener l, String[] labels, String[] cmds, String[] tooltips, Hashtable buttonMap) Make a set of JButtons, each with a label and action command from the given cmds and labels arrays. Add the buttons into a new JPanel and return it.- Parameters:
l
- Listenerlabels
- Button labels. If a label starts with icon: then we make an image button, the image path is the rest of the labelcmds
- Button action commandstooltips
- If non-null then set te tooltip on the buttonbuttonMap
- If non-null will hold a mapping from (String) command to JButton- Returns:
- JPanel that contains the buttons
-
makeApplyCancelButtons
Utility to make apply/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- The button panel
-
makeApplyButton
Utility to make apply button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- The button panel
-
makeOkCancelButtons
Utility to make ok/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- The button panel
-
makeNewOkCancelButtons
Utility to make new/ok/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- The button panel
-
makeNewOkCancelHelpButtons
Utility to make new/ok/cancel/help button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- The button panel
-
makeNewOkCancelButtons
public static JPanel makeNewOkCancelButtons(ActionListener l, String newLabel, String okLabel, String cancelLabel) Utility to make new/ok/cancel button panel- Parameters:
l
- The listener to add to the buttonsnewLabel
- Label to use for the new buttonokLabel
- Label to use for the ok buttoncancelLabel
- Label to use for the cancel button- Returns:
- Button panel
-
makeOkCancelButtons
Utility to make ok/cancel button panel- Parameters:
l
- The listener to add to the buttonsokLabel
- Label to use for the ok buttoncancelLabel
- Label to use for the cancel button- Returns:
- Button panel
-
makeApplyOkCancelButtons
Utility to make apply/ok/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- Button panel
-
makeOkHelpCancelButtons
Utility to make ok/help/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- Button panel
-
makeApplyOkHelpCancelButtons
Utility to make apply/ok/help/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- Button panel
-
makeApplyOkResetCancelButtons
Utility to make apply/ok/reset/cancel button panel- Parameters:
l
- The listener to add to the buttons- Returns:
- Button panel
-
showYesNoDialog
Show a modeful dialog, attached to the given frame, with the given message. Ask the user Yes or No.- Parameters:
frame
- Frame to attach to.message
- Message to showtitle
- Window title- Returns:
- True if user selects Yes, false if No
-
showYesNoDialog
public static boolean showYesNoDialog(Window frame, String message, String title, String yes, String no) Show a modeful dialog, attached to the given frame, with the given message. Ask the user Yes or No.- Parameters:
frame
- Frame to attach to.message
- Message to showtitle
- Window titleyes
- The Yes textno
- The No text- Returns:
- True if user selects Yes, false if No
-
insertText
Insert text into the component- Parameters:
comp
- components
- text to insert
-
showYesNoCancelDialog
Show a modeful dialog, attached to the given frame, with the given message. Ask the user Yes or No or Cancel- Parameters:
frame
- Frame to attach to.message
- Message to showtitle
- Window title- Returns:
- 0 if Yes, 1 if No, 2 if Cancel
-
showYesNoCancelDialog
public static int showYesNoCancelDialog(Window frame, String message, String title, String defaultCmd) Show a modeful dialog, attached to the given frame, with the given message. Ask the user Yes or No or Cancel- Parameters:
frame
- Frame to attach to.message
- Message to showtitle
- Window titledefaultCmd
- default for the dialog (CMD_YES, CMD_NO, CMD_CANCEL)- Returns:
- 0 if Yes, 1 if No, 2 if Cancel
-
showYesNoDialog
public static boolean showYesNoDialog(Window frame, String title, Component contents, Component src) Show a modeful dialog, attached to the given frame, with the given message. Ask the user Yes or No.- Parameters:
frame
- Frame to attach to.title
- Window titlecontents
- GUI contentssrc
- Where to show window- Returns:
- True if user selects Yes, false if No
-
showOkCancelDialog
Show a modeful Ok/Cancel dialog.- Parameters:
f
- The frame to attach totitle
- The window titlecontents
- The gui contents to showsrc
- Where should the window popup- Returns:
- True if Ok was pressed, false otherwise
-
showOkCancelDialog
public static boolean showOkCancelDialog(Window f, String title, Component contents, Component src, List actionComponents) Show a modeful Ok/Cancel dialog.- Parameters:
f
- The frame to attach totitle
- The window titlecontents
- The gui contents to showsrc
- Where should the window popupactionComponents
- If non-null then these are components in the contents (e.g., JTextField) that an action listener is added to to do the Ok on an action event- Returns:
- True if Ok was pressed, false otherwise
-
createFrame
A utility to create a frame. This also registers the frame with the LogUtil facility that tracks the recently active windows.- Parameters:
title
- Frame title- Returns:
- The frame
-
createDialog
A utility to create a dialog. If modal then this method uses the LogUtil.getCurrentWindow as the parent window of the dialog.- Parameters:
title
- Dialog titlemodal
- Is modal- Returns:
- THe dialog
-
popup
Popup an html widget at the given x/y that shows the text (or, if the text is a URI will read the URI).- Parameters:
text
- text or urix
- xy
- ymodal
- modal- Returns:
- 2 element array holding the html component and the dialog
-
createDialog
Utility to create a JDialog with a parent component. If not modal this method also registers the JDialog with the LogUtil last active window facility.- Parameters:
parent
- The parent window. May be null, a Dialog or a Frametitle
- Dialog titlemodal
- Is modal- Returns:
- The dialog
-
showOkCancelDialog
public static boolean showOkCancelDialog(Window f, String title, Component contents, Component src, List actionComponents, String okLabel) Show a modeful Ok/Cancel dialog.- Parameters:
f
- The frame to attach totitle
- The window titlecontents
- The gui contents to showsrc
- Where should the window popupactionComponents
- If non-null then these are components in the contents (e.g., JTextField) that an action listener is added to to do the Ok on an action eventokLabel
- text for the OK button- Returns:
- True if Ok was pressed, false otherwise
-
showOkCancelDialog
public static boolean showOkCancelDialog(Window f, String title, Component contents, Component src, List actionComponents, String okLabel, boolean resizable, Dimension dialogPrefSize) Show a modal Ok/Cancel dialog.- Parameters:
f
- The frame to attach totitle
- The window titlecontents
- The gui contents to showsrc
- Where should the window popupactionComponents
- If non-null then these are components in the contents (e.g., JTextField) that an action listener is added to to do the Ok on an action eventokLabel
- text for the OK buttonresizable
- Whether or not the dialog can be resized.dialogPrefSize
- If notnull
, use as preferred size of resulting dialog.- Returns:
- True if Ok was pressed, false otherwise
-
showOkDialog
Show OK dialog- Parameters:
f
- relative windowtitle
- title for the dialogcontents
- dialog contentssrc
- src component
-
makeDialog
public static int makeDialog(Window f, String title, Component contents, Component src, String[] buttonLabels) Make and show a modeful dialog with the given collection of buttons. Return the index of the button that was pushed- Parameters:
f
- Frame to attach totitle
- Window titlecontents
- GUI contentssrc
- Where to show windowbuttonLabels
- Buttons- Returns:
- Which button was pushed
-
configureStepSelection
Add a listener to the JList that pops up a menu on a right click that allos for the selection of different strides.- Parameters:
list
- list to popup on
-
showIntervalSelectionDialog
Show the list interval selection dialog- Parameters:
list
- list
-
getConfigureStepSelectionItems
popup a menu to select strides- Parameters:
list
- JListitems
- menu items
-
formLayout
Do a 2 column layout. Right align the first column. Make the width of the first column non-stretcy, second column stretchy.- Parameters:
comps
- Components to layoutrightAlignFirstColumn
- If true then right align the first column- Returns:
- Panel containing form
-
formLayout
Do a 2 column layout. Right align the first column. Make the width of the first column non-stretcy, second column stretchy.- Parameters:
comps
- Components to layout- Returns:
- Panel containing form
-
formLayout
Do a 2 column layout. Right align the first column. Use the given stretchy flags.- Parameters:
comps
- Components to layoutwidths
- WT_heights
- WT_- Returns:
- Panel containing form
-
formLayout
Do a 2 column layout. Right align the first column. Use the given stretchy flags.- Parameters:
comps
- Components to layoutwidths
- WT_heights
- WT_- Returns:
- Panel containing form
-
formLayout
public static JComponent formLayout(List comps, double[] widths, double[] heights, boolean rightAlignFirstColumn) Do a 2 column layout. Use the given stretchy flags.- Parameters:
comps
- Components to layoutwidths
- WT_heights
- WT_rightAlignFirstColumn
- If true then right align the first column.- Returns:
- Panel containing form
-
label
Create a JPanel that holds a JLabel/the given widget- Parameters:
label
- The label text to usewidget
- The widget to label- Returns:
- The panel
-
label
Create a JPanel that holds a the given widget/JLabel- Parameters:
widget
- The widget to labellabel
- The label text to use- Returns:
- The panel
-
packWindow
Add the given contents into the given frame- Parameters:
f
- The framecontents
- The contents- Returns:
- The given frame
-
packWindow
Add the given contents into the given frame- Parameters:
f
- The framecontents
- The contentsandShow
- If true then show the window.- Returns:
- The given frame
-
packDialog
Add the given contents into the given dialog- Parameters:
f
- The dialogcontents
- The contents- Returns:
- The dialog
-
makeWindow
Create a new JFrame, add the contents to it, set its location and return it.- Parameters:
title
- The window titlecontents
- The contentsx
- x locationy
- y location- Returns:
- The new JFrame
-
makeMenuBar
Create a JMenuBar and add the menus contained with the menus list If no menus then return null.- Parameters:
menus
- List if JMenu-s- Returns:
- The JMenuBar
-
getCloseDialogListener
Create a listener that will close the given dialog.- Parameters:
dialog
- The dialog to close- Returns:
- The listener that closes the dialog on an action event
-
getImageLabel
Create a JLabel that displays an image icon create from the given icon path (may be a file, resource or url).- Parameters:
icon
- The image fileorigin
- Used to lookup java resources- Returns:
- New JLabel showing image
-
getImageLabel
Create a JLabel that displays an image icon create from the given icon path (may be a file, resource or url).- Parameters:
icon
- The image file- Returns:
- New JLabel showing image
-
getImageButton
Create a JButton that displays an image icon create from the given icon path (may be a file, resource or url).- Parameters:
icon
- The image fileorigin
- Used to lookup java resources- Returns:
- New JButton showing image
-
getImageButton
Create a JButton that displays an image icon create from the given icon path (may be a file, resource or url).- Parameters:
icon
- The image fileorigin
- Used to lookup java resourceshInset
- Horizontal insetvInset
- Vertical inset- Returns:
- New JButton showing image
-
getScaledImageButton
Get a scaled image button- Parameters:
icon
- path to icon for the buttonorigin
- relative classhInset
- horizontal insetvInset
- vertical inset- Returns:
- the button
-
getImageButton
Create a JButton that displays the given image icon- Parameters:
icon
- The image icon- Returns:
- New JButton showing image
-
getImageButton
Create a JButton that displays the given image icon- Parameters:
icon
- The image iconoffset
- The spacing around the image in the JButton- Returns:
- New JButton showing image
-
getImageButton
Create a JButton that displays the given image icon- Parameters:
icon
- The image iconhinset
- The hor. spacing around the image in the JButtonvinset
- The vert. spacing around the image in the JButton- Returns:
- New JButton showing image
-
getToggleImageButton
public static JToggleButton getToggleImageButton(String icon, String selectedIcon, int hinset, int vinset, boolean addMouseOverBorder) Create a JToggleButton with the given image and, if non-null, the given selected image.- Parameters:
icon
- Image for buttonselectedIcon
- Image to use when selectedhinset
- Hor. insetvinset
- Vert. insetaddMouseOverBorder
- add a mouseover border- Returns:
- New button
-
getToggleImageButton
public static JToggleButton getToggleImageButton(ImageIcon icon, ImageIcon selectedIcon, int hinset, int vinset) Create a JToggleButton with the given image and, if non-null, the given selected image.- Parameters:
icon
- Image for buttonselectedIcon
- Image to use when selectedhinset
- Hor. insetvinset
- Vert. inset- Returns:
- New button
-
getToggleImageButton
public static JToggleButton getToggleImageButton(ImageIcon icon, ImageIcon selectedIcon, int hinset, int vinset, boolean addMouseOverBorder) Create a JToggleButton with the given image and, if non-null, the given selected image.- Parameters:
icon
- Image for buttonselectedIcon
- Image to use when selectedhinset
- Hor. insetvinset
- Vert. insetaddMouseOverBorder
- add a mouseover border- Returns:
- New button
-
makeMouseOverBorder
Make a mouse over border- Parameters:
b
- the component
-
getToggleButton
Create a toggle button with the given image.- Parameters:
iconPath
- path to imagehinset
- hor. insetvinset
- vert inset- Returns:
- button
-
getToggleButton
Create a toggle button with the given image.- Parameters:
icon
- The icon to usehinset
- hor.insetvinset
- vert. inset- Returns:
- The new button
-
getLocation
Find the location of the given componet on the screen. If any errors then return the screen center - 100- Parameters:
src
- Source component- Returns:
- Location on screen
-
showInCenter
pack and show the dialog in the center of the screen- Parameters:
dialog
- The dialog
-
packInCenter
pack the dialog in the center of the screen- Parameters:
dialog
- The dialog
-
vsplit
Create a JSplitPane in vertical mode.- Parameters:
top
- Top componentbottom
- Bottom componenttopSpace
- How much space to give the topresizeWeight
- How much weight to give the top when resizing- Returns:
- The split pane
-
vsplit
Create a JSplitPane in vertical mode.- Parameters:
top
- Top componentbottom
- Bottom componenttopSpace
- How much space to give the top- Returns:
- The split pane
-
vsplit
Create a JSplitPane in vertical mode.- Parameters:
top
- Top componentbottom
- Bottom componentresizeWeight
- How much weight to give the top when resizing- Returns:
- The split pane
-
vsplit
Create a JSplitPane in vertical mode.- Parameters:
top
- Top componentbottom
- Bottom component- Returns:
- The split pane
-
hsplit
public static JSplitPane hsplit(Component left, Component right, int leftSpace, double resizeWeight) Create a horizontally aligned JSplitPane. Give the left component the specified space.- Parameters:
left
- The left componentright
- The right componentleftSpace
- Where to put the dividerresizeWeight
- The resize weight- Returns:
- The split pane
-
hsplit
Create a horizontally aligned JSplitPane- Parameters:
left
- The left componentright
- The right componentleftSpace
- Where to put the divider- Returns:
- The split pane
-
hsplit
Create a horizontally aligned JSplitPane- Parameters:
left
- The left componentright
- The right componentresizeWeight
- How much resize weight to use- Returns:
- The split pane
-
hsplit
Create a basic horizontally aligned JSplitPane- Parameters:
left
- The left componentright
- The right component- Returns:
- The split pane
-
rLabel
Create a right aligned JLabel- Parameters:
s
- The String to use for the label- Returns:
- The label
-
cLabel
Create a center aligned JLabel- Parameters:
s
- The String to use for the label- Returns:
- The label
-
lLabel
Create a left aligned JLabel- Parameters:
s
- The String to use for the label- Returns:
- The label
-
hspace
Create a a minimally sized spacer- Parameters:
w
- The min widthh
- The min height- Returns:
- The spacer
-
getInput
Ask the user the question. Return their response or null.- Parameters:
question
- The question.label
- Extra label.initValue
- Initial value of answer- Returns:
- The user's response
-
getInput
public static String getInput(String question, String label, String initValue, String trailingLabel) Ask the user the question. Return their response or null.- Parameters:
question
- The question.label
- Extra label.initValue
- Initial value of answertrailingLabel
- Label after the text field.- Returns:
- The user's response
-
getInput
public static String getInput(String question, String label, String initValue, String trailingLabel, Object underLabel) Ask the user the question. Return their response or null.- Parameters:
question
- The question.label
- Extra label.initValue
- Initial value of answertrailingLabel
- Label after the text field.underLabel
- Label under the text field.- Returns:
- The user's response
-
getInput
public static String getInput(String question, String label, String initValue, String trailingLabel, Object underLabel, String title) Ask the user the question. Return their response or null.- Parameters:
question
- The question.label
- Extra label.initValue
- Initial value of answertrailingLabel
- Label after the text field.underLabel
- Label under the text field.title
- for the dialog box.- Returns:
- The user's response
-
getInput
public static String getInput(String question, String label, String initValue, String trailingLabel, Object underLabel, String title, int fieldWidth) Ask the user the question. Return their response or null.- Parameters:
question
- The question.label
- Extra label.initValue
- Initial value of answertrailingLabel
- Label after the text field.underLabel
- Label under the text field.title
- for the dialog box.fieldWidth
- Field width- Returns:
- The user's response
-
getInput
public static String getInput(String question, String label, String initValue, String trailingLabel, Object underLabel, String title, int fieldWidth, JComponent nearComponent) Ask the user the question. Return their response or null.- Parameters:
question
- The question.label
- Extra label.initValue
- Initial value of answertrailingLabel
- Label after the text field.underLabel
- Label under the text field.title
- for the dialog box.fieldWidth
- Field widthnearComponent
- If non-null then show the dialog near this component- Returns:
- The user's response
-
getInput
Ask the user the question. Return the answer.- Parameters:
question
- The question- Returns:
- The answer
-
askYesNo
Ask the user the question. Return yes or no.- Parameters:
title
- The window title.question
- The question.- Returns:
- True if they say yes
-
askOkCancel
Ask the user the question. Return ok or cancel.- Parameters:
title
- The window title.question
- The question.- Returns:
- True if they say ok, false otherwise
-
showDialog
Show the given component in a dialog.- Parameters:
title
- The titlecomp
- The component to show
-
addModalDialogComponent
Add the model dialog to the list- Parameters:
comp
- The component in the model dialog
-
removeModalDialogComponent
Remove the model dialog from the list- Parameters:
comp
- The component in the model dialog
-
showDialog
Show the given component in a dialog.- Parameters:
title
- The titlecomp
- The component to showparentComponent
- The parent component of the dialog.
-
toFrontModalDialogs
public static void toFrontModalDialogs()Move to the front any modal dialogs -
setListData
Procedure to set the list of items in a ComboBox- Parameters:
box
- Combobox to fillitems
- Items to add
-
anySelected
Check if there are any selected items in the combobox. We have this as a method because if the box as no items a getSelectedItem causes an error.- Parameters:
box
- The box to check- Returns:
- Any selected items.
-
setListData
Procedure to set the list of items in a ComboBox- Parameters:
box
- Combobox to fillitems
- Items to add
-
getEditableBox
Create an editable combobox with the given items. Preselect the selected item if non-null.- Parameters:
items
- Items in the boxselected
- Selected item- Returns:
- New JComboBox
-
getBoxValue
Return the selected item in the given box as an integer. Do a new Double(selected.toString()):- Parameters:
box
- The box- Returns:
- The int value of the selected item.
-
createValueBox
public static JComboBox createValueBox(ActionListener listener, String command, int initValue, List values, boolean editable) Create a combobx boxc that holds a set of integer values.- Parameters:
listener
- The action listenercommand
- Action command for boxinitValue
- Initial valuevalues
- List of Integerseditable
- Is box editable- Returns:
- The combobox
-
processXmlMenuItem
public static JMenuItem processXmlMenuItem(Node node, ActionListener listener, Hashtable menuItems) throws Exception Create the JMenuItem defined by the given xml- Parameters:
node
- Xml menu item nodelistener
- Action listener to add to the menu itemmenuItems
- Mapping from id (from xml) to JMenuItem- Returns:
- The menu item
- Throws:
Exception
-
processXmlMenuItem
public static JMenuItem processXmlMenuItem(Node node, ActionListener listener, Hashtable menuItems, Hashtable<String, ImageIcon> actionIcons) throws ExceptionCreate the JMenuItem defined by the given xml- Parameters:
node
- Xml menu item nodelistener
- Action listener to add to the menu itemmenuItems
- Mapping from id (from xml) to JMenuItemactionIcons
- mapping of string action to imageicon to use in the menu item- Returns:
- The menu item
- Throws:
Exception
-
charToKeyCode
Take the first character of the string and return the numeric key code- Parameters:
s
- The string- Returns:
- The key code of the first char of the string
-
charToKeyCode
public static int charToKeyCode(char ch) Return the numeric key code of the given character.- Parameters:
ch
- The character- Returns:
- Its key code
-
processXmlMenu
public static JMenu processXmlMenu(Node menuNode, ActionListener listener, Hashtable menuItems) throws Exception Create the JMenu from the given xml.- Parameters:
menuNode
- The menu xml nodelistener
- The action listenermenuItems
- Mapping from id to menu items- Returns:
- New JMenu
- Throws:
Exception
-
processXmlMenu
public static JMenu processXmlMenu(Node menuNode, ActionListener listener, Hashtable menuItems, Hashtable<String, ImageIcon> actionIcons) throws ExceptionCreate the JMenu from the given xml.- Parameters:
menuNode
- The menu xml nodelistener
- The action listenermenuItems
- Mapping from id to menu itemsactionIcons
- mapping of string action to imageicon to use in the menu item- Returns:
- New JMenu
- Throws:
Exception
-
processXmlMenuBar
public static JMenuBar processXmlMenuBar(Element root, JMenuBar menuBar, ActionListener listener, Hashtable menuItems) Create, if null, and ddd to the JMenuBar from the xml- Parameters:
root
- Xml rootmenuBar
- The menu barlistener
- The action listenermenuItems
- Mapping from id to menu items- Returns:
- The JMenuBar
-
processXmlMenuBar
public static JMenuBar processXmlMenuBar(Element root, JMenuBar menuBar, ActionListener listener, Hashtable menuItems, Hashtable<String, ImageIcon> actionIcons) Create, if null, and ddd to the JMenuBar from the xml- Parameters:
root
- Xml rootmenuBar
- The menu barlistener
- The action listenermenuItems
- Mapping from id to menu itemsactionIcons
- mapping of string action to imageicon to use in the menu item- Returns:
- The JMenuBar
-
getItems
return the list of items held by the combo box.- Parameters:
box
- The box- Returns:
- List of items
-
isShowing
Is the frame showing- Parameters:
f
- The frame- Returns:
- Is it showing
-
isShowing
Is the dialog showing- Parameters:
f
- The dialog- Returns:
- Is it showing
-
getImage
Get the screen image from the component- Parameters:
component
- The component.- Returns:
- Its image
- Throws:
Exception
-
showHtmlDialog
Show the given html in a window. If linkListener is non-null then add itinto the html viewer to listen for hyper link clicks.- Parameters:
html
- The htmllinkListener
- The listener- Returns:
- A 2-tuple. First element is the JDialog. Second is the JEditorPane
-
showHtmlDialog
Show the given html in a window with the given title. If linkListener is non-null then add itinto the html viewer to listen for hyper link clicks.- Parameters:
html
- The htmltitle
- The title of the windowlinkListener
- The listener- Returns:
- A 2-tuple. First element is the JFrame. Second is the JEditorPane
-
getHtmlComponent
public static Component[] getHtmlComponent(String html, HyperlinkListener linkListener, int width, int height) Make a JTextEditor component and scroller for the given html- Parameters:
html
- htmllinkListener
- Listenerwidth
- heightheight
- width- Returns:
- 2 component array. First is the editor. Second is the scroller its in
-
showHtmlDialog
public static Component[] showHtmlDialog(String html, String title, String label, HyperlinkListener linkListener, boolean modal) Show a dialog window that contains an html editor- Parameters:
html
- htmltitle
- window titlelabel
- labellinkListener
- Listenermodal
- is window modal- Returns:
- 2 component array. First is the editor. Second is the scroller its in
-
initializeExpandedPathsBeforeChange
public static Hashtable initializeExpandedPathsBeforeChange(JTree tree, DefaultMutableTreeNode root) Call this before a JTree changes. It stores into the returned hashtable state that it uses later to re-expand the paths of the jtree after its structure changes.- Parameters:
tree
- The jtreeroot
- Its tree root- Returns:
- Holds the state for later expansion
-
expandPathsAfterChange
Call this after the structure of a JTree changes to re-expand the paths.- Parameters:
tree
- The treestate
- The state. From initializeExpandedPathsBeforeChangeroot
- The tree root
-
doTreeSearch
public static GuiUtils.TreeSearchResults doTreeSearch(JTree tree, Object lastState, String nodeDesc, JComponent near) Popup a dialog and search the given tree for a tree node that matches the user provided string.- Parameters:
tree
- Tree to searchlastState
- For successive searches, this keeps state aroundnodeDesc
- A descriptive term for the node for when we tell something to the usernear
- If non-null then show the input dialog near this component- Returns:
- Some state for successive searches
-
limitMenuSize
This takes the list of JMenuItems and, for each JMenu, will ensure that there are no more than size number of items in any sub menu. It uses name (e.g., Group) to make the sub-menus, e.g., Group 1, Group 2, ...- Parameters:
items
- List of JMenuItemsname
- The name suffix to usesize
- Max size of a menu
-
limitMenuSize
This ensures that there are no more than size number of items in any sub menu. It uses name (e.g., Group) to make the sub-menus, e.g., Group 1, Group 2, ...- Parameters:
menu
- The menuname
- The name suffix to usesize
- Max size of a menu
-
limitMenuSize
This ensures that there are no more than size number of items in any sub menu. It uses name (e.g., Group) to make the sub-menus, e.g., Group 1, Group 2, ...- Parameters:
menu
- The menuname
- The name suffix to usesize
- Max size of a menurecurse
- If true then limit the size of all sub menus
-
doTreeSearch
public static GuiUtils.TreeSearchResults doTreeSearch(JTree tree, Object lastState, String nodeDesc, JComponent near, String originalPhrase) Search the given tree- Parameters:
tree
- the treelastState
- last statenodeDesc
- the node descriptionnear
- the near componentoriginalPhrase
- the search phrase- Returns:
- the results
-
toCsv
Convert the given table model to comma separated string- Parameters:
model
- The table model to write- Returns:
- CSV representation of the given table model
-
toCsv
Convert the given table model to comma separated string- Parameters:
model
- The table model to writeincludeColumnNames
- true to include the column names- Returns:
- CSV representation of the given table model
-
exportAsCsv
Write out the given table model as a csv file- Parameters:
model
- The table model to write
-
exportAsCsv
Write out the given table model as a comma separated value (CSV) file prepending the header.- Parameters:
header
- a header to prepend to the tablemodel
- The table model to write
-
exportAsCsv
Write out the given table model as a comma separated value (CSV) file prepending the header.- Parameters:
header
- a header to prepend to the tablemodel
- The table model to writeincludeColumnNames
- true to include the column names
-
exportAsCsv
Export a table as csv- Parameters:
header
- header for the outputmodel
- table modelfilename
- file name to export to
-
exportAsCsv
public static void exportAsCsv(String header, TableModel model, String filename, boolean includeColumnNames) Export a table as csv- Parameters:
header
- header for the outputmodel
- table modelfilename
- file name to export toincludeColumnNames
- true to include the column names
-
setupDirectoryChooser
Set up a directory chooser- Parameters:
btn
- button for choosing directorydirectoryFld
- directory field
-
setupFileChooser
Set up a directory chooser- Parameters:
btn
- button for choosing directorydirectoryFld
- directory fieldjustDirectories
- flag for just looking at directories
-
makeCheckbox
Make a checkbox. Automatically call the set'property' method on the object- Parameters:
label
- Labelobject
- Object to callproperty
- Name of property to get/set value- Returns:
- The checkbox
-
makeCheckbox
Make a checkbox. Automatically call the set'property' method on the object- Parameters:
label
- Labelobject
- Object to callproperty
- Name of property to get/set valuearg
- Optional arg to pass to method- Returns:
- The checkbox
-
makeRadioButtons
public static JRadioButton[] makeRadioButtons(List labels, int selectedIndex, Object object, String methodName) Make a set of radio buttons- Parameters:
labels
- labelsselectedIndex
- which one is onobject
- Object to callmethodName
- The method- Returns:
- The radio buttons
-
makeButton
Make a JButton. Call methodName on object when button pressed.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to call- Returns:
- The button
-
makeButton
Make a JButton. Call methodName on object when button pressed. Pass in given arg if non-null.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.- Returns:
- The button
-
makeButton
public static JButton makeButton(String label, Object object, String methodName, Object arg, String tooltip) Make a JButton. Call methodName on object when button pressed. Pass in given arg if non-null.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.tooltip
- if non-null then set the tooltip on the button- Returns:
- The button
-
makeActionListener
Make an ActionListener. Call methodName on object when button pressed. Pass in given arg if non-null.- Parameters:
object
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.- Returns:
- The action listener
-
invokeInSwingThread
RUn the given runnable in the swing event dispatch thread- Parameters:
runnable
- runnable to run
-
makeImageButton
Make a JButton. Call methodName on object when button pressed.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to call- Returns:
- The button
-
makeImageButton
Make a JButton. Call methodName on object when button pressed. Pass in given arg if non-null.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.- Returns:
- The button
-
makeImageButton
public static JButton makeImageButton(String label, Object object, String methodName, Object arg, boolean addMouseOverBorder) Make a JButton. Call methodName on object when button pressed. Pass in given arg if non-null.- Parameters:
label
- Labelobject
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.addMouseOverBorder
- add a mouse-over border- Returns:
- The button
-
addActionListener
public static JComponent addActionListener(JComponent comp, Object object, String methodName, Object arg) Adds an action listener to the button. Call methodName on object when button pressed. Pass in given arg if non-null.- Parameters:
comp
- The componentobject
- Object to callmethodName
- Method name to callarg
- Pass this to method name if non-null.- Returns:
- The button
-
makeDynamicMenu
Create a menu and add a listener to it that removes all items and calls the given method on te given object with the menu as an argument.- Parameters:
name
- Menu nameobject
- Object to callmethodName
- method to invoke- Returns:
- The menu
-
makeDynamicMenu
public static JMenu makeDynamicMenu(String name, Object object, String methodName, boolean doRemoveAll) Create a menu and add a listener to it that removes all items and calls the given method on te given object with the menu as an argument.- Parameters:
name
- Menu nameobject
- Object to callmethodName
- method to invokedoRemoveAll
- true to remove all first- Returns:
- The menu
-
makeComboBox
public static JComboBox makeComboBox(List items, Object selected, boolean editable, Object listener, String methodName) Make a JComboBox- Parameters:
items
- items for the boxselected
- the selected itemeditable
- flag for whether this is editable or notlistener
- Listener for changesmethodName
- method to call when item changes- Returns:
- the combo box
-
makeComboBox
public static JComboBox makeComboBox(List items, Object selected, boolean editable, Object listener, String methodName, boolean inAThread) Make a JComboBox- Parameters:
items
- items for the boxselected
- the selected itemeditable
- flag for whether this is editable or notlistener
- Listener for changesmethodName
- method to call when item changesinAThread
- Call the method in a thread- Returns:
- the combo box
-
makeComboBox
Make a combo box from a set of values and labels- Parameters:
values
- integer valueslabels
- labels for valuescurrent
- current one to select- Returns:
- the JComboBox
-
setValueOfBox
Set the value of the box- Parameters:
box
- the box to setvalue
- the default valuevalues
- the valueslabels
- labels for the values
-
getValueFromBox
Get the integer value from a JComboBox of integer items- Parameters:
box
- the box to use- Returns:
- the integer value
-
makeSlider
Make a JSlider- Parameters:
min
- minimum valuemax
- maximum valuevalue
- initial valuelistener
- listener for changesmethodName
- method to call when change occurs- Returns:
- JSlider
-
makeSlider
public static JSlider makeSlider(int min, int max, int value, Object listener, String methodName, boolean updateAsMove) Make a JSlider- Parameters:
min
- minimum valuemax
- maximum valuevalue
- initial valuelistener
- listener for changesmethodName
- method to call when change occursupdateAsMove
- If true we call the listener as the slider moves.- Returns:
- JSlider
-
getFontSizeList
Get a list of font sizes- Returns:
- list of font sizes
-
getFontList
Get a list of fonts- Returns:
- vector of fonts
-
makeTwoFacedFont
Make a TwoFacedObject from a font for displaying in a combobox.- Parameters:
f
- Font to use- Returns:
- corresponding TwoFacedObject
-
makeRowVisible
Make the given row in the table visible- Parameters:
table
- The tablerow
- The row
-
scrollToTop
Scroll the given component to the top- Parameters:
editor
- editor to scroll
-
addMouseListenerRecurse
Add a mouse listener to all components of a container- Parameters:
listener
- the mouse listenerc
- the container
-
addKeyListenerRecurse
Add a key listener to all components of a container- Parameters:
listener
- the key listenerc
- the container
-
distance
public static double distance(double x1, double y1, double x2, double y2) Calculate distance between 2 points.- Parameters:
x1
- x1y1
- y1x2
- x2y2
- y2- Returns:
- distance
-
distance
public static double distance(double[] p1, double[] p2) Get distance between- Parameters:
p1
- Fromp2
- To- Returns:
- Distance
-
distance
public static double distance(int[] p1, int[] p2) Get distance between- Parameters:
p1
- Fromp2
- To- Returns:
- Distance
-
distance
Calculate distance between point and rectangle. This will give the min distance from the 4 corners and the sides.- Parameters:
x
- xy
- yr
- rect- Returns:
- distance_
-
makeVerticalLabel
Make a vertical label- Parameters:
text
- text- Returns:
- vertical label
-
doMultiSplitPane
Make an evenly balanced group of split panes for the given components- Parameters:
comps
- List of componentshsplit
- horizontal or vertical- Returns:
- split panes
-
getNestedTabbedPane
Make a JTabbedPane without some of its border- Returns:
- Tabbed pane
-
getNestedTabbedPane
Make a JTabbedPane without some of its border- Parameters:
orient
- tab orientation- Returns:
- Tabbed pane
-
getNestedTabbedPane
Make a JTabbedPane without some of its border- Parameters:
orient
- tab orientationtop
- top borderleft
- left borderbottom
- bottom borderright
- right border- Returns:
- Tabbed pane
-
makeSliderPopup
This creates a JButton and a JSlider. The intent is that the button can be placed in some GUI. On click a small, decorationless modeful dialog that contains the slider is popped up. Focus is set on the slider and a return or escape or press of the close button closes the dialog. slider events are routed to the change listener.- Parameters:
min
- slider min valuemax
- slider max valuevalue
- slider valuelistener
- slider change listener- Returns:
- a 2 element array containing the button and the slider
-
positionAndFitToScreen
Position and fit a window to the screen- Parameters:
window
- window to fitbounds
- new bounds
-
toggleHeavyWeightComponents
Walk the tree and set any heavyweight components visibility. Note: We don't turn off any component that is under the javax.swing package If we encounter a JTabbedPane then only show the components that are in the selected tab- Parameters:
comp
- Componentvisible
- On/off
-
checkHeavyWeightComponents
Walk the components of the tab and toggle the heavyweight components visiblity- Parameters:
tab
- tab
-
resetHeavyWeightComponents
Walk the components of the tab and toggle the heavyweight components visiblity- Parameters:
tab
- tab
-
handleHeavyWeightComponentsInTabs
Add a change listener to the tab that toggles on any heavy weight components in the selected tab and turns off any in the non-selected tabs.- Parameters:
tab
- tab
-
main
test- Parameters:
args
- args- Throws:
Exception
- on badness
-
makeFileBrowseButton
Make a button that pops up a file browser and sets the text of the given field with the selected file- Parameters:
fld
- Field to set- Returns:
- The button
-
makeFileBrowseButton
Make a button that pops up a file browser and sets the text of the given field with the selected file- Parameters:
fld
- Field to setfilters
- File filters. May be null.- Returns:
- The button
-
makeFileBrowseButton
public static JButton makeFileBrowseButton(JTextComponent fld, boolean chooseDirectory, List filters) Make a button that pops up a file browser and sets the text of the given field with the selected file- Parameters:
fld
- Field to setchooseDirectory
- Select a directoryfilters
- File filters. May be null.- Returns:
- The button
-
doMakeFontBox
Make a font selector box- Parameters:
f
- Font to select in the box- Returns:
- The box
-
doMakeFontSizeBox
Make a box for setting the font size- Parameters:
size
- Selected size- Returns:
- The box
-
italicizeFont
Italicize the font on the given component- Parameters:
comp
- The component- Returns:
- the component
-
popupUnitMenu
This pops up a menu near the given comp and allows the user to select a unit name which gets put into the given fld- Parameters:
fld
- The fld to setcomp
- THe component to popup the menu near
-
getIconsInMenus
public static boolean getIconsInMenus()Do we show icons in the menus- Returns:
- show icons in menus
-
setIconsInMenus
public static void setIconsInMenus(boolean doIcons) Do we show icons in the menus- Parameters:
doIcons
- show icons
-
setIcon
Set the icon on the button. This button is usually a JMenu or JMenuItem If the setIconsInMenus flag is false then don't do this- Parameters:
button
- The buttoniconPath
- The icon path- Returns:
- Just return the button so you can do something like menu.add(GuiUtils.setIcon(menuItem,"/icon path"));
-
setSelectedItems
_more_- Parameters:
list
- _more_selected
- _more_
-
getItems
_more_- Parameters:
list
- _more_- Returns:
- _more_
-
getLocalName
_more_- Parameters:
n
- _more_local
- _more_- Returns:
- _more_
-
getLocalName
_more_- Parameters:
n
- _more_local
- _more_addHtml
- _more_- Returns:
- _more_
-
appendText
_more_- Parameters:
fld
- _more_s
- _more_delimiter
- _more_
-
addKeyBindings
_more_- Parameters:
comp
- _more_
-
moveSubtreesToTop
_more_- Parameters:
parent
- _more_
-
makeHeader
Utility to create a header that is a label and a line.- Parameters:
label
- Header label- Returns:
- Header
-
getAttribute
Get the given name-d attribute from the given element. If not found return the dflt argument.- Parameters:
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.- Returns:
- The attribute value or the dflt if not found.
-
getAttribute
_more_- Parameters:
attrs
- _more_name
- _more_dflt
- _more_- Returns:
- _more_
-
getAttribute
_more_- Parameters:
attrs
- _more_name
- _more_dflt
- _more_- Returns:
- _more_
-
getAttribute
_more_- Parameters:
attrs
- _more_name
- _more_- Returns:
- _more_
-
findChildren
_more_- Parameters:
parent
- _more_tag
- _more_- Returns:
- _more_
-
getInt
Get an integer value from the text field- Parameters:
fld
- text field- Returns:
- integer value shown
-
getValue
Get an double value from the text field- Parameters:
fld
- text field- Returns:
- double value shown
-
setApplicationTitle
_more_- Parameters:
title
- _more_
-
getApplicationTitle
_more_- Returns:
- _more_
-
doMacMenubar
public static boolean doMacMenubar()_more_- Returns:
- _more_
-
isControlKey
Is the given event a control (or meta for the mac) key- Parameters:
event
- _more_- Returns:
- _more_
-
isControlKey
_more_- Parameters:
event
- _more_keyCode
- _more_- Returns:
- _more_
-
isMac
public static boolean isMac()Is this running on a Mac?- Returns:
- true if running on Mac
-
isDeleteEvent
_more_- Parameters:
e
- _more_- Returns:
- _more_
-
decorateFrame
_more_- Parameters:
frame
- _more_menuBar
- _more_
-
showUrl
_more_- Parameters:
s
- _more_- Throws:
Exception
- _more_
-
addLinkListener
_more_- Parameters:
editor
- _more_
-
showFrameAsDialog
popup but a modal dialog with input Jframe
-