public class GUIUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GUIUtil.FileChooserWithOverwritePrompting |
static class |
GUIUtil.Location |
Modifier and Type | Field and Description |
---|---|
static javax.swing.filechooser.FileFilter |
ALL_FILES_FILTER |
static java.lang.String |
dbf |
static java.lang.String |
dbfDesc |
static java.lang.String |
fme |
static java.lang.String |
fmeDesc |
static java.lang.String |
gml |
static java.lang.String |
gmlDesc |
static java.lang.String |
jml |
static java.lang.String |
jmlDesc |
static int |
PERPIXEL_TRANSLUCENCY |
static int |
SHAPED_WINDOW |
static java.lang.String |
shp |
static java.lang.String |
shpDesc |
static java.lang.String |
shx |
static java.lang.String |
shxDesc |
static int |
UNIFORM_TRANSLUCENCY |
static java.lang.String |
wkt |
static java.lang.String |
wktaDesc |
static java.lang.String |
wktDesc |
static java.lang.String |
xml |
static java.lang.String |
xmlDesc |
Constructor and Description |
---|
GUIUtil() |
Modifier and Type | Method and Description |
---|---|
static java.awt.geom.Point2D |
add(java.awt.geom.Point2D a,
java.awt.geom.Point2D b) |
static void |
addInternalFrameListener(javax.swing.JDesktopPane pane,
javax.swing.event.InternalFrameListener listener)
Listens to all internal frames (current and future) in a JDesktopPane.
|
static java.awt.Color |
alphaColor(java.awt.Color color,
int alpha) |
static void |
centre(java.awt.Component componentToMove,
java.awt.Component componentToCentreOn)
Centres the first component on the second
|
static void |
centreOnScreen(java.awt.Component componentToMove)
Centres the component on the screen
|
static void |
centreOnWindow(java.awt.Component componentToMove)
Centres the component on its window
|
static void |
centreOnWindow(java.awt.Window windowToMove)
Centrer the window on its parent window
|
static void |
chooseGoodColumnWidths(javax.swing.JTable table)
Sets the column widths based on the first row.
|
static java.awt.Cursor |
createCursor(java.awt.Image image,
java.awt.Point hotSpot) |
static java.awt.Cursor |
createCursorFromIcon(java.awt.Image iconImage) |
static javax.swing.filechooser.FileFilter |
createFileFilter(java.lang.String description,
java.lang.String[] extensions) |
static javax.swing.JFileChooser |
createJFileChooserWithExistenceChecking() |
static javax.swing.JFileChooser |
createJFileChooserWithOverwritePrompting() |
static javax.swing.JFileChooser |
createJFileChooserWithOverwritePrompting(java.lang.String ext) |
static javax.swing.Timer |
createRestartableSingleEventTimer(int delay,
java.awt.event.ActionListener listener)
Returns a Timer that fires once, after the delay.
|
static ValidatingTextField |
createSyncdTextField(javax.swing.JSlider s) |
static ValidatingTextField |
createSyncdTextField(javax.swing.JSlider s,
int columns) |
static void |
dispose(javax.swing.JInternalFrame internalFrame,
javax.swing.JDesktopPane desktopPane)
Ensures that the next frame is activated when #dispose is called
explicitly, in JDK 1.4.
|
static void |
doNotRoundDoubles(javax.swing.JTable table) |
static java.lang.String |
escapeHTML(java.lang.String value)
Convenience method by default escaping everything.
|
static java.lang.String |
escapeHTML(java.lang.String value,
boolean escapeSpaces,
boolean escapeNewlines)
Returns a string suitable for embedding as HTML.
|
static void |
fixClicks(java.awt.Component c)
Fix for Sun Java Bug 4398733: if you click in an inactive JInternalFrame,
the mousePressed and mouseReleased events will be fired, but not the
mouseClicked event.
|
static void |
fixEditableComboBox(javax.swing.JComboBox cb)
Workaround for Java Bug 4648654 "REGRESSION: Editable JComboBox focus
misbehaves under Windows look and feel, proposed by Kleopatra
(fastegal@addcom.de).
|
static java.awt.datatransfer.Transferable |
getContents(java.awt.datatransfer.Clipboard clipboard)
The JVM's clipboard implementation is buggy (see bugs 4644554 and 4522198
in Sun's Java bug database).
|
static java.awt.GraphicsDevice |
getDefaultScreenDevice() |
static java.awt.Component |
getDescendantOfClass(java.lang.Class c,
java.awt.Container container) |
static java.lang.String |
getExtension(java.io.File f) |
static void |
handleThrowable(java.lang.Throwable t,
java.awt.Component parent) |
static void |
highlightForDebugging(javax.swing.JComponent component,
java.awt.Color color)
Highlights a given component with a given color.
|
static void |
invokeOnEventThread(java.lang.Runnable r)
GUI operations should be performed only on the AWT event dispatching
thread.
|
static boolean |
isPerPixelTranslucencySupported() |
static boolean |
isShapedWindowSupported() |
static boolean |
isUniformTranslucencySupported() |
static java.util.List |
items(javax.swing.JComboBox comboBox) |
static javax.swing.JTextArea |
makeTabMoveFocus(javax.swing.JTextArea textArea)
Based on Green, Roedy.
|
static java.awt.geom.Point2D |
multiply(java.awt.geom.Point2D v,
double x) |
static java.lang.String |
nameWithoutExtension(java.io.File file) |
static javax.swing.ImageIcon |
overlay(javax.swing.ImageIcon icon,
javax.swing.ImageIcon overlay,
int x,
int y)
overlay an icon over another icon
|
static javax.swing.ImageIcon |
overlay(javax.swing.ImageIcon image,
javax.swing.ImageIcon overlay,
int x,
int y,
float alpha,
java.awt.Image mask)
overlay an icon over another icon respecting mask (b/w image)
|
static javax.swing.ImageIcon |
pad(javax.swing.ImageIcon icon,
int border)
enlarge icon by padding border pixels onto it
|
static void |
removeChoosableFileFilters(javax.swing.JFileChooser fc) |
static javax.swing.ImageIcon |
resize(javax.swing.ImageIcon icon,
int extent) |
static java.io.File[] |
selectedFiles(javax.swing.JFileChooser chooser)
Work around Java Bug 4437688 "JFileChooser.getSelectedFile() returns
nothing when a file is selected" [Jon Aquino]
|
static void |
setBounds(java.awt.Component componentToMove,
GUIUtil.Location location,
int width,
int height,
java.awt.Component other) |
static void |
setLocation(java.awt.Component componentToMove,
GUIUtil.Location location,
java.awt.Component other) |
static void |
setSelectedWithClick(javax.swing.JCheckBox checkBox,
boolean selected)
Calls #doClick so that events are fired.
|
static void |
shrinkFont(javax.swing.JComponent component) |
static java.awt.geom.Point2D |
subtract(java.awt.geom.Point2D a,
java.awt.geom.Point2D b) |
static int |
swingThreadPriority() |
static void |
sync(javax.swing.JCheckBox c1,
javax.swing.JCheckBox c2) |
static void |
sync(javax.swing.JSlider s1,
javax.swing.JSlider s2) |
static void |
sync(javax.swing.JSlider s,
ValidatingTextField t) |
static void |
syncEnabledStates(javax.swing.JComponent c1,
javax.swing.JComponent c2) |
static javax.swing.ImageIcon |
toDisabledIcon(javax.swing.ImageIcon icon) |
static javax.swing.event.DocumentListener |
toDocumentListener(java.awt.event.ActionListener listener) |
static javax.swing.ImageIcon |
toGrayScale(javax.swing.ImageIcon icon)
convert icon to grayscale
|
static javax.swing.event.InternalFrameListener |
toInternalFrameListener(java.awt.event.ActionListener listener) |
static javax.swing.event.ListDataListener |
toListDataListener(java.awt.event.ActionListener listener) |
static java.awt.Component |
topCard(java.awt.Container c) |
static java.awt.Color |
toSimulatedTransparency(java.awt.Color color) |
static javax.swing.ImageIcon |
toSmallIcon(javax.swing.ImageIcon icon)
Resizes icon to 16 x 16.
|
static javax.swing.ImageIcon |
toSmallIcon(javax.swing.ImageIcon icon,
int width)
Resize icon to specified width
|
static double |
trueAscent(java.awt.font.TextLayout layout)
Returns the distance from the baseline to the top of the text's bounding
box.
|
static java.lang.String |
truncateString(java.lang.String s,
int maxLength) |
public static final java.lang.String dbf
public static final java.lang.String dbfDesc
public static final java.lang.String fme
public static final java.lang.String fmeDesc
public static final java.lang.String gml
public static final java.lang.String gmlDesc
public static final java.lang.String jml
public static final java.lang.String jmlDesc
public static final java.lang.String shp
public static final java.lang.String shpDesc
public static final java.lang.String shx
public static final java.lang.String shxDesc
public static final java.lang.String wkt
public static final java.lang.String wktDesc
public static final java.lang.String wktaDesc
public static final java.lang.String xml
public static final java.lang.String xmlDesc
public static final javax.swing.filechooser.FileFilter ALL_FILES_FILTER
public static final int UNIFORM_TRANSLUCENCY
public static final int PERPIXEL_TRANSLUCENCY
public static final int SHAPED_WINDOW
public static final java.lang.String escapeHTML(java.lang.String value)
value
- public static final java.lang.String escapeHTML(java.lang.String value, boolean escapeSpaces, boolean escapeNewlines)
Based on code from Jason Sherman. See http://www.w3schools.com/html/html_asciiref.asp
public static java.lang.String getExtension(java.io.File f)
public static java.awt.Color alphaColor(java.awt.Color color, int alpha)
public static void centre(java.awt.Component componentToMove, java.awt.Component componentToCentreOn)
componentToMove
- Description of the ParametercomponentToCentreOn
- Description of the Parameterpublic static void centreOnScreen(java.awt.Component componentToMove)
componentToMove
- Description of the Parameterpublic static void centreOnWindow(java.awt.Component componentToMove)
componentToMove
- Description of the Parameterpublic static void centreOnWindow(java.awt.Window windowToMove)
windowToMove
- window to be centered on its parent windowpublic static void chooseGoodColumnWidths(javax.swing.JTable table)
table
- Description of the Parameterpublic static javax.swing.JFileChooser createJFileChooserWithExistenceChecking()
public static javax.swing.JFileChooser createJFileChooserWithOverwritePrompting()
public static javax.swing.JFileChooser createJFileChooserWithOverwritePrompting(java.lang.String ext)
public static void doNotRoundDoubles(javax.swing.JTable table)
public static void fixEditableComboBox(javax.swing.JComboBox cb)
cb
- Description of the Parameterpublic static void handleThrowable(java.lang.Throwable t, java.awt.Component parent)
public static void invokeOnEventThread(java.lang.Runnable r) throws java.lang.InterruptedException, java.lang.reflect.InvocationTargetException
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException
public static java.lang.String nameWithoutExtension(java.io.File file)
public static void removeChoosableFileFilters(javax.swing.JFileChooser fc)
public static javax.swing.filechooser.FileFilter createFileFilter(java.lang.String description, java.lang.String[] extensions)
extensions
- e.g. txtpublic static java.awt.Color toSimulatedTransparency(java.awt.Color color)
color
- a Color with possibly an alpha less than 255public static java.lang.String truncateString(java.lang.String s, int maxLength)
public static java.awt.geom.Point2D subtract(java.awt.geom.Point2D a, java.awt.geom.Point2D b)
public static java.awt.geom.Point2D add(java.awt.geom.Point2D a, java.awt.geom.Point2D b)
public static java.awt.geom.Point2D multiply(java.awt.geom.Point2D v, double x)
public static java.awt.datatransfer.Transferable getContents(java.awt.datatransfer.Clipboard clipboard)
public static double trueAscent(java.awt.font.TextLayout layout)
public static javax.swing.ImageIcon resize(javax.swing.ImageIcon icon, int extent)
public static javax.swing.ImageIcon toSmallIcon(javax.swing.ImageIcon icon)
public static javax.swing.ImageIcon toSmallIcon(javax.swing.ImageIcon icon, int width)
icon
- width
- public static javax.swing.ImageIcon pad(javax.swing.ImageIcon icon, int border)
icon
- border
- public static javax.swing.ImageIcon toGrayScale(javax.swing.ImageIcon icon)
icon
- public static javax.swing.ImageIcon overlay(javax.swing.ImageIcon icon, javax.swing.ImageIcon overlay, int x, int y)
icon
- overlay
- x
- y
- public static javax.swing.ImageIcon overlay(javax.swing.ImageIcon image, javax.swing.ImageIcon overlay, int x, int y, float alpha, java.awt.Image mask)
image
- overlay
- x
- y
- alpha
- mask
- public static int swingThreadPriority()
public static void fixClicks(java.awt.Component c)
public static void addInternalFrameListener(javax.swing.JDesktopPane pane, javax.swing.event.InternalFrameListener listener)
public static javax.swing.event.DocumentListener toDocumentListener(java.awt.event.ActionListener listener)
public static javax.swing.event.ListDataListener toListDataListener(java.awt.event.ActionListener listener)
public static javax.swing.event.InternalFrameListener toInternalFrameListener(java.awt.event.ActionListener listener)
public static javax.swing.Timer createRestartableSingleEventTimer(int delay, java.awt.event.ActionListener listener)
public static ValidatingTextField createSyncdTextField(javax.swing.JSlider s)
public static ValidatingTextField createSyncdTextField(javax.swing.JSlider s, int columns)
public static void sync(javax.swing.JSlider s, ValidatingTextField t)
public static void syncEnabledStates(javax.swing.JComponent c1, javax.swing.JComponent c2)
public static void sync(javax.swing.JSlider s1, javax.swing.JSlider s2)
public static void sync(javax.swing.JCheckBox c1, javax.swing.JCheckBox c2)
public static java.util.List items(javax.swing.JComboBox comboBox)
public static void setSelectedWithClick(javax.swing.JCheckBox checkBox, boolean selected)
public static void setLocation(java.awt.Component componentToMove, GUIUtil.Location location, java.awt.Component other)
public static void setBounds(java.awt.Component componentToMove, GUIUtil.Location location, int width, int height, java.awt.Component other)
public static void highlightForDebugging(javax.swing.JComponent component, java.awt.Color color)
public static java.awt.Component topCard(java.awt.Container c)
public static java.io.File[] selectedFiles(javax.swing.JFileChooser chooser)
public static javax.swing.ImageIcon toDisabledIcon(javax.swing.ImageIcon icon)
public static java.awt.Component getDescendantOfClass(java.lang.Class c, java.awt.Container container)
public static void dispose(javax.swing.JInternalFrame internalFrame, javax.swing.JDesktopPane desktopPane)
public static java.awt.Cursor createCursorFromIcon(java.awt.Image iconImage)
public static java.awt.Cursor createCursor(java.awt.Image image, java.awt.Point hotSpot)
public static javax.swing.JTextArea makeTabMoveFocus(javax.swing.JTextArea textArea)
public static void shrinkFont(javax.swing.JComponent component)
public static java.awt.GraphicsDevice getDefaultScreenDevice()
public static boolean isUniformTranslucencySupported()
public static boolean isPerPixelTranslucencySupported()
public static boolean isShapedWindowSupported()