Class GUIUtil
java.lang.Object
com.vividsolutions.jump.workbench.ui.GUIUtil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FileFilterstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Point2Dstatic voidaddInternalFrameListener(JDesktopPane pane, InternalFrameListener listener) Listens to all internal frames (current and future) in a JDesktopPane.static ColoralphaColor(Color color, int alpha) static voidCentres the first component on the secondstatic voidcentreOnScreen(Component componentToMove) Centres the component on the screenstatic voidcentreOnWindow(Component componentToMove) Centres the component on its windowstatic voidcentreOnWindow(Window windowToMove) Center the window on its parent windowstatic voidchooseGoodColumnWidths(JTable table) Sets the column widths based on the first row.static CursorcreateCursor(Image cursorImage, Point hotSpot, String name) static CursorcreateCursorFromIcon(Image iconImage) static CursorcreateCursorOld(Image image, Point hotSpot) static FileFiltercreateFileFilter(String description, String[] extensions) static JFileChooserstatic JFileChooserstatic JFileChooserstatic TimercreateRestartableSingleEventTimer(int delay, ActionListener listener) Returns a Timer that fires once, after the delay.static ValidatingTextFieldstatic 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) Convenience method by default escaping everything.static StringescapeHTML(String value, boolean escapeSpaces, boolean escapeNewlines) Returns a string suitable for embedding as HTML.static voidFix 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 voidWorkaround for Java Bug 4648654 "REGRESSION: Editable JComboBox focus misbehaves under Windows look and feel, proposed by Kleopatra (fastegal@addcom.de).static ImageIconCreate an ImageIcon from given color and dimensionsstatic TransferablegetContents(Clipboard clipboard) The JVM's clipboard implementation is buggy (see bugs 4644554 and 4522198 in Sun's Java bug database).static GraphicsDevicestatic 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 voidGUI operations should be performed only on the AWT event dispatching thread.static booleanstatic booleanstatic booleanstatic Liststatic JTextAreamakeTabMoveFocus(JTextArea textArea) Based on Green, Roedy.static Point2Dstatic StringnameWithoutExtension(File file) static ImageIconOverlay an icon over another iconstatic ImageIconoverlay an icon over another icon respecting mask (b/w image)static ImageIconEnlarge icon by padding border pixels onto itstatic ImageIconEnlarge icon by padding it by given number of pixelsstatic voidstatic Imagestatic ImageIconresize to a square, even non square imagesstatic ImageIconresizes to the given dimensions. take care to calculate them properly if you want to keep aspect ratiostatic File[]selectedFiles(JFileChooser chooser) Work around Java Bug 4437688 "JFileChooser.getSelectedFile() returns nothing when a file is selected" [Jon Aquino]static voidsetBounds(Component componentToMove, GUIUtil.Location location, int width, int height, Component other) static voidsetLocation(Component componentToMove, GUIUtil.Location location, Component other) static voidsetSelectedWithClick(JCheckBox checkBox, boolean selected) Calls #doClick so that events are fired.static booleanshowConfirmOverwriteDialog(Component parent, File file) utility method to show an overwrite confirmation yes/no dialogstatic voidshrinkFont(JComponent component) static Point2Dstatic intstatic voidstatic voidsync(JSlider s, ValidatingTextField t) static voidstatic voidsyncEnabledStates(JComponent c1, JComponent c2) static ImageIcontoDisabledIcon(ImageIcon icon) static DocumentListenertoDocumentListener(ActionListener listener) static ImageIcontoGrayScale(ImageIcon icon) Convert icon to grayscalestatic Imageconvert Icon to Imagestatic ImageIcontoImageIcon(Icon icon) static InternalFrameListenertoInternalFrameListener(ActionListener listener) static ListDataListenertoListDataListener(ActionListener listener) static Componentstatic ColortoSimulatedTransparency(Color color) static ImageIcontoSmallIcon(ImageIcon icon) Resizes icon to 16 x 16.static ImageIcontoSmallIcon(ImageIcon icon, int width) Resize icon to specified widthstatic 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 Details
-
dbf
- See Also:
-
dbfDesc
- See Also:
-
fme
- See Also:
-
fmeDesc
- See Also:
-
gml
- See Also:
-
gmlDesc
- See Also:
-
jml
- See Also:
-
jmlDesc
- See Also:
-
shp
- See Also:
-
shpDesc
- See Also:
-
shx
- See Also:
-
shxDesc
- See Also:
-
wkt
- See Also:
-
wktDesc
- See Also:
-
wktaDesc
- See Also:
-
xml
- See Also:
-
xmlDesc
- See Also:
-
ALL_FILES_FILTER
-
UNIFORM_TRANSLUCENCY
public static final int UNIFORM_TRANSLUCENCY- See Also:
-
PERPIXEL_TRANSLUCENCY
public static final int PERPIXEL_TRANSLUCENCY- See Also:
-
SHAPED_WINDOW
public static final int SHAPED_WINDOW- See Also:
-
-
Constructor Details
-
GUIUtil
public GUIUtil()
-
-
Method Details
-
escapeHTML
-
escapeHTML
Returns a string suitable for embedding 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
-
getExtension
-
alphaColor
-
centre
-
centreOnScreen
Centres the component on the screen- Parameters:
componentToMove- Description of the Parameter
-
centreOnWindow
Centres the component on its window- Parameters:
componentToMove- Description of the Parameter
-
centreOnWindow
Center the window on its parent window- Parameters:
windowToMove- window to be centered on its parent window
-
chooseGoodColumnWidths
Sets the column widths based on the first row.- Parameters:
table- Description of the Parameter
-
createJFileChooserWithExistenceChecking
-
createJFileChooserWithOverwritePrompting
-
createJFileChooserWithOverwritePrompting
-
showConfirmOverwriteDialog
-
doNotRoundDoubles
-
fixEditableComboBox
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
-
handleThrowable
-
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. -
nameWithoutExtension
-
removeChoosableFileFilters
-
createFileFilter
- Parameters:
extensions- e.g. txt
-
toSimulatedTransparency
-
truncateString
-
subtract
-
add
-
multiply
-
getContents
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
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. -
toImage
-
toImageIcon
-
fromColor
-
resize
-
resize
resizes to the given dimensions. take care to calculate them properly if you want to keep aspect ratio- Parameters:
icon- imageIcon to resizeextent_x- new width of the iconextent_y- new height of the icon- Returns:
- the resized ImageIcon
-
resize
-
toSmallIcon
-
toSmallIcon
-
pad
-
pad
Enlarge icon by padding it by given number of pixels- Parameters:
icon- Icon to be paddedtop- number of pixels to add to the topleft- number of pixels to add to the leftbottom- number of pixels to add to the bottomright- number of pixels to add to the right- Returns:
- the new Padded ImageIcon
-
toGrayScale
-
overlay
Overlay an icon over another icon- Parameters:
icon- ImageIcon to be overlayedoverlay- overlay ImageIconx- x position of the overlay in the sourcey- y position of the overlay in the source- Returns:
- an ImageIcon combining source image and overlaid image
-
overlay
public static ImageIcon overlay(ImageIcon image, ImageIcon overlay, int x, int y, float alpha, Image mask) overlay an icon over another icon respecting mask (b/w image)- Parameters:
image- source ImageIcon to be overlaidoverlay- overlay ImageIconx- x position of the overlay in the sourcey- y position of the overlay in the sourcealpha- alpha coefficient used to combine ovelay to source imagemask- source image will only be overlaid within this mask- Returns:
- an ImageIcon combining source image and overlaid image within the mask
-
swingThreadPriority
public static int swingThreadPriority() -
fixClicks
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
Listens to all internal frames (current and future) in a JDesktopPane. -
toDocumentListener
-
toListDataListener
-
toInternalFrameListener
-
createRestartableSingleEventTimer
Returns a Timer that fires once, after the delay. The delay can be restarted by restarting the Timer. -
createSyncdTextField
-
createSyncdTextField
-
sync
- See Also:
-
syncEnabledStates
-
sync
-
sync
-
items
-
setSelectedWithClick
Calls #doClick so that events are fired. -
setLocation
public static void setLocation(Component componentToMove, GUIUtil.Location location, Component other) -
setBounds
public static void setBounds(Component componentToMove, GUIUtil.Location location, int width, int height, Component other) -
highlightForDebugging
Highlights a given component with a given color. Great for GridBagLayout debugging. -
topCard
-
selectedFiles
Work around Java Bug 4437688 "JFileChooser.getSelectedFile() returns nothing when a file is selected" [Jon Aquino] -
toDisabledIcon
-
getDescendantOfClass
-
dispose
Ensures that the next frame is activated when #dispose is called explicitly, in JDK 1.4. JDK 1.3 didn't have this problem. -
createCursorFromIcon
-
createCursorOld
-
createCursor
-
makeTabMoveFocus
-
shrinkFont
-
getDefaultScreenDevice
-
isUniformTranslucencySupported
public static boolean isUniformTranslucencySupported() -
isPerPixelTranslucencySupported
public static boolean isPerPixelTranslucencySupported() -
isShapedWindowSupported
public static boolean isShapedWindowSupported()
-