public class GuiUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GuiUtils.RelativeLocation |
Modifier and Type | Field and Description |
---|---|
static int |
ABOVE
Place one component above another.
|
static int |
BELOW
Place one component below another.
|
static int |
CENTER
Align centers.
|
static int |
LEFT
Place one component completely to the left of another.
|
static int |
RIGHT
Place one component completely to the right of another.
|
Modifier and Type | Method and Description |
---|---|
static javax.swing.JButton |
addHorizontalButton(javax.swing.JComponent comp,
java.lang.String cmd,
java.awt.event.ActionListener listener,
java.lang.String toolTip)
Creates a horizontal button and adds it to a JComponent.
|
static javax.swing.JButton |
addVerticalButton(javax.swing.JComponent comp,
java.lang.String cmd,
java.awt.event.ActionListener listener,
java.lang.String toolTip)
Creates a vertical button and adds it to a JComponent.
|
static boolean |
confirmAction(java.awt.Component comp,
java.lang.String msg) |
static boolean |
confirmOverwrite(java.awt.Component comp,
java.io.File file) |
static boolean |
containsComponent(java.awt.Container parent,
java.awt.Component comp) |
static boolean |
containsMenuComponent(javax.swing.JMenu parent,
java.awt.Component comp) |
static java.awt.Component |
createBoxFiller() |
static javax.swing.JButton |
createHorizontalButton(java.lang.String cmd,
java.awt.event.ActionListener listener,
java.lang.String toolTip)
Create a button to be arranged horizontally within a panel (such as the
"Cancel", "Done" buttons at the bottom of a dialog.
|
static javax.swing.JMenuItem |
createMenuItem(java.awt.event.ActionListener listener,
java.lang.String cmd,
java.lang.String toolTip) |
static javax.swing.border.TitledBorder |
createTitledPanelBorder(java.lang.String title) |
static javax.swing.JButton |
createVerticalButton(java.lang.String cmd,
java.awt.event.ActionListener listener,
java.lang.String toolTip)
Creates a button to be arranged vertically in JComponent.
|
static java.awt.Dimension |
getMaxPreferredSize(java.util.Collection<? extends javax.swing.JComponent> comps)
Returns the maximum dimension for a set of components.
|
static java.awt.Rectangle |
getScreenBounds(java.awt.Component ref)
Gets the current screen bounds of a component.
|
static java.awt.Point |
getScreenLocation(java.awt.Component ref,
double xr,
double yr)
Gets the current screen location of a specified point within a reference
component.
|
static java.awt.Rectangle |
getVirtualScreenBounds() |
static void |
growSize(java.awt.Dimension size0,
java.awt.Dimension size1)
Grow size0 as needed to to accommodate size1
|
static int |
indexOfComponent(java.awt.Container parent,
java.awt.Component comp) |
static int |
indexOfMenuComponent(javax.swing.JMenu parent,
java.awt.Component comp) |
static javax.swing.ImageIcon |
loadIcon(java.lang.Object ref,
java.lang.String path) |
static javax.swing.ImageIcon |
loadIcon(java.lang.String fullpath) |
static void |
locateAbove(java.awt.Window win,
java.awt.Component ref)
Locates a window above the window containing a specified reference
component.
|
static void |
locateBelow(java.awt.Window win,
java.awt.Component ref)
Locates a window below the window containing a specified reference
component.
|
static void |
locateCenter(java.awt.Window win,
java.awt.Component ref)
Center a window on the window containing a specified
reference component.
|
static void |
locateHorizontally(java.awt.Window win,
java.awt.Component ref,
int location)
Sets the horizonal position of a window relative to another component.
|
static void |
locateLeft(java.awt.Window win,
java.awt.Component ref)
Locates a window to the left of the window containing a specified
reference component.
|
static void |
locateRelative(java.awt.Window win,
java.awt.Component ref,
GuiUtils.RelativeLocation loc)
Locates a window relative to the window containing a specific
component.
|
static void |
locateRelative(java.awt.Window win,
java.awt.Component ref,
GuiUtils.RelativeLocation hloc,
GuiUtils.RelativeLocation vloc)
Locates a window relative to a reference window containing a specific
component.
|
static void |
locateRelative(java.awt.Window win,
java.awt.Rectangle bounds,
double px,
double py,
double wx,
double wy)
Locates a window relative to a given set of screen bounds.
|
static void |
locateRight(java.awt.Window win,
java.awt.Component ref)
Locates a window to the right of the window containing a specified
reference component.
|
static void |
locateVertically(java.awt.Window win,
java.awt.Component ref,
int location)
Sets the vertical position of a window relative to another component.
|
static void |
repackComponentWindow(java.awt.Component c) |
static void |
setFixedHeight(java.awt.Component comp,
int h)
Sets the height of a component to a rigidly fixed value
|
static void |
setFixedSize(java.util.Collection<? extends javax.swing.JComponent> comps,
java.awt.Dimension size)
Sets the size of a set of components to be as rigidly fixed as we
possibly can.
|
static void |
setFixedSize(java.awt.Component comp,
java.awt.Dimension size)
Sets the size of a component to be as rigidly fixed as we possibly can.
|
static void |
setFixedSize(java.awt.Component comp,
int w,
int h)
Sets the size of a component to be a rigidly fixed as we possibly can.
|
static void |
setFixedWidth(java.awt.Component comp,
int w)
Sets the width of a component to a rigidly fixed value
|
static void |
setItalicFont(javax.swing.JComponent jcomp) |
static void |
showError(java.awt.Component comp,
java.lang.String msg) |
static void |
showError(java.awt.Component comp,
java.lang.String msg,
java.lang.Exception e) |
static void |
showNotice(java.awt.Component comp,
java.lang.String msg) |
static void |
showResult(java.awt.Component comp,
java.lang.String msg) |
static void |
showWarning(java.awt.Component comp,
java.lang.String msg) |
public static final int CENTER
public static final int LEFT
public static final int RIGHT
public static final int ABOVE
public static final int BELOW
public static void growSize(java.awt.Dimension size0, java.awt.Dimension size1)
public static java.awt.Dimension getMaxPreferredSize(java.util.Collection<? extends javax.swing.JComponent> comps)
public static void setFixedSize(java.util.Collection<? extends javax.swing.JComponent> comps, java.awt.Dimension size)
public static void setFixedSize(java.awt.Component comp, java.awt.Dimension size)
public static void setFixedSize(java.awt.Component comp, int w, int h)
public static void setFixedWidth(java.awt.Component comp, int w)
public static void setFixedHeight(java.awt.Component comp, int h)
public static java.awt.Component createBoxFiller()
public static java.awt.Point getScreenLocation(java.awt.Component ref, double xr, double yr)
ref
- reference componentxr
- normalized horizontal point locationyr
- normalized vertical point locationpublic static java.awt.Rectangle getScreenBounds(java.awt.Component ref)
public static void locateHorizontally(java.awt.Window win, java.awt.Component ref, int location)
LEFT
, RIGHT
, or CENTER
.
This placement may be altered in order to keep the window on the screen.win
- window to be locatedref
- reference componentlocation
- desired horizonal location of the window relative to the componentpublic static void locateVertically(java.awt.Window win, java.awt.Component ref, int location)
ABOVE
, BELOW
, or
CENTER
. This placement may be altered in
order to keep the window on the screen.win
- window to be locatedref
- reference componentlocation
- desired horizonal location of the window relative to the componentpublic static void locateRelative(java.awt.Window win, java.awt.Rectangle bounds, double px, double py, double wx, double wy)
public static void locateRelative(java.awt.Window win, java.awt.Component ref, GuiUtils.RelativeLocation loc)
win
- window to be locatedref
- reference component contained by the reference windowloc
- desired relative location of win
with respect
to the reference window.public static void locateRelative(java.awt.Window win, java.awt.Component ref, GuiUtils.RelativeLocation hloc, GuiUtils.RelativeLocation vloc)
win
- window to be locatedref
- reference component contained by the reference windowhloc
- if non-null
, gives the desired relative horizontal
location of win
with respect to the reference window. Must be
GuiUtils.RelativeLocation.LEFT
, GuiUtils.RelativeLocation.RIGHT
, or GuiUtils.RelativeLocation.CENTER
.vloc
- if non-null
, gives the desired relative vertical
location of win
with respect to the reference window. Must be
GuiUtils.RelativeLocation.ABOVE
, GuiUtils.RelativeLocation.BELOW
, or GuiUtils.RelativeLocation.CENTER
.public static void locateCenter(java.awt.Window win, java.awt.Component ref)
public static void locateRight(java.awt.Window win, java.awt.Component ref)
public static void locateLeft(java.awt.Window win, java.awt.Component ref)
public static void locateAbove(java.awt.Window win, java.awt.Component ref)
public static void locateBelow(java.awt.Window win, java.awt.Component ref)
public static java.awt.Rectangle getVirtualScreenBounds()
public static javax.swing.ImageIcon loadIcon(java.lang.Object ref, java.lang.String path)
public static javax.swing.ImageIcon loadIcon(java.lang.String fullpath)
public static int indexOfComponent(java.awt.Container parent, java.awt.Component comp)
public static boolean containsComponent(java.awt.Container parent, java.awt.Component comp)
public static int indexOfMenuComponent(javax.swing.JMenu parent, java.awt.Component comp)
public static boolean containsMenuComponent(javax.swing.JMenu parent, java.awt.Component comp)
public static void setItalicFont(javax.swing.JComponent jcomp)
public static void repackComponentWindow(java.awt.Component c)
public static javax.swing.border.TitledBorder createTitledPanelBorder(java.lang.String title)
public static javax.swing.JMenuItem createMenuItem(java.awt.event.ActionListener listener, java.lang.String cmd, java.lang.String toolTip)
public static void showError(java.awt.Component comp, java.lang.String msg)
public static void showError(java.awt.Component comp, java.lang.String msg, java.lang.Exception e)
public static void showWarning(java.awt.Component comp, java.lang.String msg)
public static void showNotice(java.awt.Component comp, java.lang.String msg)
public static void showResult(java.awt.Component comp, java.lang.String msg)
public static boolean confirmAction(java.awt.Component comp, java.lang.String msg)
public static boolean confirmOverwrite(java.awt.Component comp, java.io.File file)
public static javax.swing.JButton createHorizontalButton(java.lang.String cmd, java.awt.event.ActionListener listener, java.lang.String toolTip)
cmd
- name and command associated with the buttonlistener
- action listener for the button commandtoolTip
- if not null
, specifies tool tip textpublic static javax.swing.JButton addHorizontalButton(javax.swing.JComponent comp, java.lang.String cmd, java.awt.event.ActionListener listener, java.lang.String toolTip)
comp
- component to which the button should be addedcmd
- name and command associated with the buttonlistener
- action listener for the button commandtoolTip
- if not null
, specifies tool tip textpublic static javax.swing.JButton createVerticalButton(java.lang.String cmd, java.awt.event.ActionListener listener, java.lang.String toolTip)
cmd
- name and command associated with the buttonlistener
- action listener for the button commandtoolTip
- if not null
, specifies tool tip textpublic static javax.swing.JButton addVerticalButton(javax.swing.JComponent comp, java.lang.String cmd, java.awt.event.ActionListener listener, java.lang.String toolTip)
comp
- component to which the button should be addedcmd
- name and command associated with the buttonlistener
- action listener for the button commandtoolTip
- if not null
, specifies tool tip text