Class GUIUtil
- java.lang.Object
-
- org.locationtech.jts.jump.workbench.ui.GUIUtil
-
public class GUIUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGUIUtil.FileChooserWithOverwritePromptingstatic classGUIUtil.Location
-
Field Summary
Fields Modifier and Type Field Description static FileFilterALL_FILES_FILTERstatic Stringdbfstatic StringdbfDescstatic Stringfmestatic StringfmeDescstatic Stringgmlstatic StringgmlDescstatic Stringjmlstatic StringjmlDescstatic Stringshpstatic StringshpDescstatic Stringshxstatic StringshxDescstatic Stringwktstatic StringwktaDescstatic StringwktDescstatic Stringxmlstatic StringxmlDesc
-
Constructor Summary
Constructors Constructor Description GUIUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Point2Dadd(Point2D a, Point2D b)static voidaddInternalFrameListener(JDesktopPane pane, InternalFrameListener listener)Listens to all internal frames (current and future) in a JDesktopPane.static ColoralphaColor(Color color, int alpha)static voidcentre(Component componentToMove, Component componentToCentreOn)Centres the first component on the secondstatic voidcentreOnScreen(Component componentToMove)Centres the component on the screenstatic voidcentreOnWindow(Component componentToMove)Centres the component on its windowstatic voidchooseGoodColumnWidths(JTable table)Sets the column widths based on the first row.static CursorcreateCursor(Image image, Point hotSpot)static CursorcreateCursorFromIcon(Image iconImage)static FileFiltercreateFileFilter(String description, String[] extensions)static JFileChoosercreateJFileChooserWithExistenceChecking()static JFileChoosercreateJFileChooserWithOverwritePrompting()static TimercreateRestartableSingleEventTimer(int delay, ActionListener listener)Returns a Timer that fires once, after the delay.static ValidatingTextFieldcreateSyncdTextField(JSlider s)static ValidatingTextFieldcreateSyncdTextField(JSlider s, int columns)static voiddispose(JInternalFrame internalFrame, JDesktopPane desktopPane)Ensures that the next frame is activated when #dispose is called explicitly, in JDK 1.4.static voiddoNotRoundDoubles(JTable table)static StringescapeHTML(String value, boolean escapeSpaces, boolean escapeNewlines)Returns a string suitable for embeddind as HTML.static voidfixClicks(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 voidfixEditableComboBox(JComboBox cb)Workaround for Java Bug 4648654 "REGRESSION: Editable JComboBox focus misbehaves under Windows look and feel, proposed by Kleopatra (fastegal@addcom.de).static TransferablegetContents(Clipboard clipboard)The JVM's clipboard implementation is buggy (see bugs 4644554 and 4522198 in Sun's Java bug database).static ComponentgetDescendantOfClass(Class c, Container container)static StringgetExtension(File f)static voidhandleThrowable(Throwable t, Component parent)static voidhighlightForDebugging(JComponent component, Color color)Highlights a given component with a given color.static voidinvokeOnEventThread(Runnable r)GUI operations should be performed only on the AWT event dispatching thread.static Listitems(JComboBox comboBox)static JTextAreamakeTabMoveFocus(JTextArea textArea)Based on Green, Roedy.static Point2Dmultiply(Point2D v, double x)static StringnameWithoutExtension(File file)static voidremoveChoosableFileFilters(JFileChooser fc)static ImageIconresize(ImageIcon icon, int extent)static File[]selectedFiles(JFileChooser chooser)Work around Java Bug 4437688 "JFileChooser.getSelectedFile() returns nothing when a file is selected" [Jon Aquino]static voidsetLocation(Component componentToMove, GUIUtil.Location location, Component other)static voidsetSelectedWithClick(JCheckBox checkBox, boolean selected)Calls #doClick so that events are fired.static Point2Dsubtract(Point2D a, Point2D b)static intswingThreadPriority()static voidsync(JCheckBox c1, JCheckBox c2)static voidsync(JSlider s1, JSlider s2)static voidsync(JSlider s, ValidatingTextField t)static voidsyncEnabledStates(JComponent c1, JComponent c2)static ImageIcontoDisabledIcon(ImageIcon icon)static DocumentListenertoDocumentListener(ActionListener listener)static InternalFrameListenertoInternalFrameListener(ActionListener listener)static ListDataListenertoListDataListener(ActionListener listener)static ComponenttopCard(Container c)static ColortoSimulatedTransparency(Color color)static ImageIcontoSmallIcon(ImageIcon icon)Resizes icon to 16 x 16.static doubletrueAscent(TextLayout layout)Returns the distance from the baseline to the top of the text's bounding box.static StringtruncateString(String s, int maxLength)
-
-
-
Field Detail
-
dbf
public static final String dbf
- See Also:
- Constant Field Values
-
dbfDesc
public static final String dbfDesc
- See Also:
- Constant Field Values
-
fme
public static final String fme
- See Also:
- Constant Field Values
-
fmeDesc
public static final String fmeDesc
- See Also:
- Constant Field Values
-
gml
public static final String gml
- See Also:
- Constant Field Values
-
gmlDesc
public static final String gmlDesc
- See Also:
- Constant Field Values
-
jml
public static final String jml
- See Also:
- Constant Field Values
-
jmlDesc
public static final String jmlDesc
- See Also:
- Constant Field Values
-
shp
public static final String shp
- See Also:
- Constant Field Values
-
shpDesc
public static final String shpDesc
- See Also:
- Constant Field Values
-
shx
public static final String shx
- See Also:
- Constant Field Values
-
shxDesc
public static final String shxDesc
- See Also:
- Constant Field Values
-
wkt
public static final String wkt
- See Also:
- Constant Field Values
-
wktDesc
public static final String wktDesc
- See Also:
- Constant Field Values
-
wktaDesc
public static final String wktaDesc
- See Also:
- Constant Field Values
-
xml
public static final String xml
- See Also:
- Constant Field Values
-
xmlDesc
public static final String xmlDesc
- See Also:
- Constant Field Values
-
ALL_FILES_FILTER
public static final FileFilter ALL_FILES_FILTER
-
-
Method Detail
-
escapeHTML
public static final String escapeHTML(String value, boolean escapeSpaces, boolean escapeNewlines)
Returns a string suitable for embeddind as HTML. That is, all characters which have a special meaning in HTML are escaped as character codes.Based on code from Jason Sherman. See http://www.w3schools.com/html/html_asciiref.asp
-
centre
public static void centre(Component componentToMove, Component componentToCentreOn)
Centres the first component on the second- Parameters:
componentToMove- Description of the ParametercomponentToCentreOn- Description of the Parameter
-
centreOnScreen
public static void centreOnScreen(Component componentToMove)
Centres the component on the screen- Parameters:
componentToMove- Description of the Parameter
-
centreOnWindow
public static void centreOnWindow(Component componentToMove)
Centres the component on its window- Parameters:
componentToMove- Description of the Parameter
-
chooseGoodColumnWidths
public static void chooseGoodColumnWidths(JTable table)
Sets the column widths based on the first row.- Parameters:
table- Description of the Parameter
-
createJFileChooserWithExistenceChecking
public static JFileChooser createJFileChooserWithExistenceChecking()
-
createJFileChooserWithOverwritePrompting
public static JFileChooser createJFileChooserWithOverwritePrompting()
-
doNotRoundDoubles
public static void doNotRoundDoubles(JTable table)
-
fixEditableComboBox
public static void fixEditableComboBox(JComboBox cb)
Workaround for Java Bug 4648654 "REGRESSION: Editable JComboBox focus misbehaves under Windows look and feel, proposed by Kleopatra (fastegal@addcom.de). Also see Java Bug 4673880 "REGRESSION: Modified editable JComboBox in Windows LAF does not release focus." This bug started occurring in Java 1.4.0.- Parameters:
cb- Description of the Parameter
-
invokeOnEventThread
public static void invokeOnEventThread(Runnable r) throws InterruptedException, InvocationTargetException
GUI operations should be performed only on the AWT event dispatching thread. Blocks until the Runnable is finished.
-
removeChoosableFileFilters
public static void removeChoosableFileFilters(JFileChooser fc)
-
createFileFilter
public static FileFilter createFileFilter(String description, String[] extensions)
- Parameters:
extensions- e.g. txt
-
toSimulatedTransparency
public static Color toSimulatedTransparency(Color color)
- Parameters:
color- a Color with possibly an alpha less than 255- Returns:
- a Color with alpha equal to 255, but equivalent to the original translucent colour on a white background
-
getContents
public static Transferable getContents(Clipboard clipboard)
The JVM's clipboard implementation is buggy (see bugs 4644554 and 4522198 in Sun's Java bug database). This method is a workaround that returns null if an exception is thrown, as suggested in the bug reports.
-
trueAscent
public static double trueAscent(TextLayout layout)
Returns the distance from the baseline to the top of the text's bounding box. Unlike the usual ascent, which is independent of the actual text. Note that "True ascent" is not a standard term.
-
swingThreadPriority
public static int swingThreadPriority()
-
fixClicks
public static void fixClicks(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.
-
addInternalFrameListener
public static void addInternalFrameListener(JDesktopPane pane, InternalFrameListener listener)
Listens to all internal frames (current and future) in a JDesktopPane.
-
toDocumentListener
public static DocumentListener toDocumentListener(ActionListener listener)
-
toListDataListener
public static ListDataListener toListDataListener(ActionListener listener)
-
toInternalFrameListener
public static InternalFrameListener toInternalFrameListener(ActionListener listener)
-
createRestartableSingleEventTimer
public static Timer createRestartableSingleEventTimer(int delay, ActionListener listener)
Returns a Timer that fires once, after the delay. The delay can be restarted by restarting the Timer.
-
createSyncdTextField
public static ValidatingTextField createSyncdTextField(JSlider s)
-
createSyncdTextField
public static ValidatingTextField createSyncdTextField(JSlider s, int columns)
-
sync
public static void sync(JSlider s, ValidatingTextField t)
-
syncEnabledStates
public static void syncEnabledStates(JComponent c1, JComponent c2)
-
setSelectedWithClick
public static void setSelectedWithClick(JCheckBox checkBox, boolean selected)
Calls #doClick so that events are fired.
-
setLocation
public static void setLocation(Component componentToMove, GUIUtil.Location location, Component other)
-
highlightForDebugging
public static void highlightForDebugging(JComponent component, Color color)
Highlights a given component with a given color. Great for GridBagLayout debugging.
-
selectedFiles
public static File[] selectedFiles(JFileChooser chooser)
Work around Java Bug 4437688 "JFileChooser.getSelectedFile() returns nothing when a file is selected" [Jon Aquino]
-
dispose
public static void dispose(JInternalFrame internalFrame, JDesktopPane desktopPane)
Ensures that the next frame is activated when #dispose is called explicitly, in JDK 1.4. JDK 1.3 didn't have this problem.
-
-