|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gui.GUIUtils
public final class GUIUtils
This class contains helper methods for the GUI.
Nested Class Summary | |
---|---|
static interface |
GUIUtils.AWTEventListener
|
private static class |
GUIUtils.IconScaler
Diese Klasse dient dazu aus einem vorhandenen Icon ein neues Icon herzustellen. |
static interface |
GUIUtils.IIconResizer
Defines a resize factor for icons that is especially useful if the font size is altered. |
static interface |
GUIUtils.NativeGUILibrary
|
static class |
GUIUtils.Screen
|
private static class |
GUIUtils.ToolTipMouseListener
|
static class |
GUIUtils.WindowDocker
|
Field Summary | |
---|---|
private static java.util.Vector |
AWT_EVENT_LISTENERS
|
private static GUIUtils.IIconResizer |
DEFAULT_RESIZER
|
private static GUIUtils.NativeGUILibrary |
DUMMY_GUI_LIBRARY
|
private static int |
MAXIMUM_TEXT_LENGTH
|
private static boolean |
ms_bCapturingAWTEvents
|
private static java.util.Hashtable |
ms_iconCache
|
private static boolean |
ms_loadImages
|
private static GUIUtils.AWTEventListener |
ms_mouseListener
|
private static java.awt.Point |
ms_mousePosition
|
private static GUIUtils.NativeGUILibrary |
ms_nativeGUILibrary
|
private static GUIUtils.IIconResizer |
ms_resizer
|
private static java.lang.String |
MSG_COPY_FROM_CLIP
|
static java.lang.String |
MSG_DEFAULT_IMGAGE_PATH
The default path to store images. |
static java.lang.String |
MSG_DEFAULT_IMGAGE_PATH_LOWCOLOR
Images with a smaller pixes size than 16 bit should be stored in this path. |
private static java.lang.String |
MSG_PASTE_FILE
|
private static java.lang.String |
MSG_SAVED_TO_CLIP
|
private static GUIUtils.IIconResizer |
RESIZER
|
private static java.lang.Object |
SYNC_MOUSE_POSITION
|
Constructor Summary | |
---|---|
GUIUtils()
|
Method Summary | |
---|---|
static void |
addAWTEventListener(GUIUtils.AWTEventListener a_listener)
|
static java.awt.event.MouseListener |
addTimedTooltipListener(javax.swing.JComponent c)
|
private static void |
adjustFontSize(java.lang.Object a_fontObject,
float a_resize)
Resizes a specific default font of the UIManager by a fixed factor. |
static void |
centerOnScreen(java.awt.Window a_window)
Centers a window relative to the default screen. |
static void |
centerOnWindow(java.awt.Window a_window,
java.awt.Window a_parent)
Positions a window on the screen centered to a parent window. |
static javax.swing.ImageIcon |
combine(javax.swing.ImageIcon a_one,
javax.swing.ImageIcon a_two)
Combines two images vertically to one image. |
static javax.swing.JButton |
createButton(java.lang.String messageKey)
|
static javax.swing.JLabel |
createLabel(java.lang.String messageKey)
Convenience function to create a JLabel with the message belonging to the specified key |
static javax.swing.JLabel |
createLabel(java.lang.String[] messageKeys)
Generalization of the other createLabel methods. |
static javax.swing.JLabel |
createLabel(java.lang.String messageKey1,
java.lang.String messageKey2)
Convenience function to create a JLabel with two slash-separated messages belonging to the specified two keys |
static javax.swing.JLabel |
createMultiLineLabel(java.lang.String messageKey,
int width)
Convenience function to create a JLabel that can display large messages. |
static javax.swing.Icon |
createScaledIcon(javax.swing.Icon a_icon,
GUIUtils.IIconResizer a_resizer)
|
static javax.swing.ImageIcon |
createScaledImageIcon(javax.swing.ImageIcon a_icon,
GUIUtils.IIconResizer a_resizer)
|
static javax.swing.JTextPane |
createSelectableAndResizeableLabel(java.awt.Component a_parent)
Creates a JTextPane that may be used to simulate a selectable and resizeable JLabel. |
static void |
exitWithNoMessagesError(java.lang.String a_resourceBundleFilename)
|
static java.lang.String |
getCountryFromServiceLocation(ServiceLocation a_loc)
|
static GUIUtils.Screen |
getCurrentScreen(java.awt.Component a_component)
|
static GUIUtils.Screen |
getCurrentScreen(java.awt.Window a_window)
|
private static java.awt.Rectangle |
getDefaultScreenBounds(java.awt.Window a_window)
Returns the bounds of the default screen. |
static GUIUtils.IIconResizer |
getIconResizer()
|
static java.awt.Dimension |
getMaxSize(java.util.Vector aComponents)
getMaxSize: takes a Vector of JComponents and returns a Dimension with width and height equivalent to the maximum width and height among the Components of the Vector |
static java.awt.Point |
getMiddlePoint(java.awt.Window a_window)
|
static java.awt.Point |
getMousePosition()
Returns the current mouse position on the screen. |
static java.awt.Point |
getMousePosition(java.awt.Component a_component)
|
private static GUIUtils.Screen |
getOverlappingScreen(GUIUtils.Screen a_screen,
java.awt.Window a_window)
Checks if a screen overlaps with the default screen and trims the screen area if needed. |
static java.awt.Window |
getParentWindow(java.awt.Component a_component)
Finds the first parent that is a window. |
static java.awt.Point |
getRelativePosition(java.awt.Point a_positionOnScreen,
java.awt.Component a_component)
|
static GUIUtils.Screen[] |
getScreens(java.awt.Window a_window)
|
static java.awt.datatransfer.Clipboard |
getSystemClipboard()
Returns the system-wide clipboard. |
static java.lang.String |
getTextFromClipboard(java.awt.Component a_requestingComponent)
|
private static java.lang.String |
getTextFromClipboard(java.awt.Component a_requestingComponent,
boolean a_bUseTextArea)
|
static java.awt.Dimension |
getTotalSize(java.util.Vector aComponents)
getTotalSize: takes a Vector of JComponents and returns a Dimension with width and height equivalent to the cumulative width and height of all the Components of the Vector Typically, you'll only use either height or width (e.g. |
static boolean |
hasJavaOnTop()
|
private static void |
interruptAWTEventThread()
|
static boolean |
isAlwaysOnTop(java.awt.Component a_component)
|
static boolean |
isAlwaysOnTop(java.awt.Window a_Window)
Returns if the alwaysOnTop method of JRE 1.5 is set on a given Window. |
static boolean |
isLoadingImagesStopped()
|
static boolean |
isMouseButton(java.awt.event.MouseEvent a_event,
int a_buttonMask)
Tests which mouse button was the cause for the specified MouseEvent. |
static javax.swing.ImageIcon |
loadImageIcon(java.lang.String a_strRelativeImagePath)
Loads an ImageIcon from the classpath or the current directory. |
static javax.swing.ImageIcon |
loadImageIcon(java.lang.String a_strRelativeImagePath,
boolean a_bSync)
Loads an ImageIcon from the classpath or the current directory. |
static javax.swing.ImageIcon |
loadImageIcon(java.lang.String a_strRelativeImagePath,
boolean a_bSync,
boolean a_bScale)
Loads an ImageIcon from the classpath or the current directory. |
private static javax.swing.ImageIcon |
loadImageIconInternal(java.net.URL a_imageURL)
|
static void |
moveToUpRightCorner(java.awt.Window a_window)
Moves the given Window to the upright corner of the default screen. |
static void |
positionRightUnderWindow(java.awt.Window a_window,
java.awt.Window a_parent)
Positions a window on the screen relative to a parent window so that its position is optimised. |
static java.util.Vector |
registerLookAndFeelClasses(java.io.File a_file)
Registers all instanciable subclasses of javax.swing.LookAndFeel from a file in the UIManager. |
static void |
removeAWTEventListener(GUIUtils.AWTEventListener a_listener)
|
static void |
resizeAllFonts(float a_resize)
Resizes all fonts of the UIManager by a fixed factor. |
static boolean |
restoreLocation(java.awt.Window a_window,
java.awt.Point a_location)
Sets a window to the specified position and tries to put the window inside the screen by altering the position if needed. |
static boolean |
restoreSize(java.awt.Window a_window,
java.awt.Dimension a_size)
Sets a window to the specified size and tries to put the window inside the screen by altering the size if needed. |
static void |
saveTextToClipboard(java.lang.String strText,
java.awt.Component a_requestingComponent)
|
static boolean |
setAlwaysOnTop(java.awt.Component a_component,
boolean a_bOnTop)
|
static boolean |
setAlwaysOnTop(java.awt.Window a_Window,
boolean a_bOnTop)
Tries to use the method setAlwaysOnTop of JRE 1.5. |
static void |
setEqualWidths(java.util.Vector aComponents,
java.awt.Dimension aDimension)
Takes a Vector of components, and sets the width of all components to the width of the Dimension passsed as parameter Just like @see setSizes(), except it only affects the width, and leaves height unchanged |
static void |
setFontStyle(java.awt.Component a_component,
int a_style)
|
static void |
setIconResizer(GUIUtils.IIconResizer a_resizer)
|
static void |
setLoadImages(boolean a_bLoadImages)
Stops loading of images, e.g. |
static void |
setLocationRelativeTo(java.awt.Component a_component,
java.awt.Window a_movedWindow)
|
static void |
setNativeGUILibrary(GUIUtils.NativeGUILibrary a_library)
|
static void |
setSizes(java.util.Vector aComponents,
java.awt.Dimension aDimension)
setSizes: takes a Vector of JCoponents and sets them all to the Dimension passed as parameter (sets preferredSize as well as maximumSize) |
static int |
showMonitoredFileChooser(javax.swing.JFileChooser a_chooser,
java.awt.Component a_parent)
This method shows a JFileChooser. |
static java.lang.String |
trim(java.lang.String a_strOriginal)
Shortens a text received from the IS or in a certificate so that it is not to long to display. |
static java.lang.String |
trim(java.lang.String a_strOriginal,
int a_maximumLength)
Shortens a text received from the IS or in a certificate so that it is not to long to display. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MSG_DEFAULT_IMGAGE_PATH
public static final java.lang.String MSG_DEFAULT_IMGAGE_PATH_LOWCOLOR
private static final java.lang.String MSG_PASTE_FILE
private static final java.lang.String MSG_COPY_FROM_CLIP
private static final java.lang.String MSG_SAVED_TO_CLIP
private static final int MAXIMUM_TEXT_LENGTH
private static boolean ms_loadImages
private static boolean ms_bCapturingAWTEvents
private static java.awt.Point ms_mousePosition
private static final java.lang.Object SYNC_MOUSE_POSITION
private static GUIUtils.AWTEventListener ms_mouseListener
private static final java.util.Vector AWT_EVENT_LISTENERS
private static final GUIUtils.IIconResizer DEFAULT_RESIZER
private static GUIUtils.IIconResizer ms_resizer
private static final GUIUtils.NativeGUILibrary DUMMY_GUI_LIBRARY
private static GUIUtils.NativeGUILibrary ms_nativeGUILibrary
private static final GUIUtils.IIconResizer RESIZER
private static java.util.Hashtable ms_iconCache
Constructor Detail |
---|
public GUIUtils()
Method Detail |
---|
public static final GUIUtils.IIconResizer getIconResizer()
public static void setLoadImages(boolean a_bLoadImages)
public static boolean isLoadingImagesStopped()
public static final void setIconResizer(GUIUtils.IIconResizer a_resizer)
public static javax.swing.ImageIcon loadImageIcon(java.lang.String a_strRelativeImagePath)
a_strRelativeImagePath
- the relative resource path or filename of the Image
public static javax.swing.ImageIcon loadImageIcon(java.lang.String a_strRelativeImagePath, boolean a_bSync)
a_strRelativeImagePath
- the relative resource path or filename of the Imagea_bSync
- true if the image should be loaded synchronously; false otherwise
public static javax.swing.ImageIcon loadImageIcon(java.lang.String a_strRelativeImagePath, boolean a_bSync, boolean a_bScale)
a_strRelativeImagePath
- the relative resource path or filename of the Imagea_bSync
- true if the image should be loaded synchronously; false otherwisea_bScale
- if the icon should be auto-scaled
private static javax.swing.ImageIcon loadImageIconInternal(java.net.URL a_imageURL)
public static javax.swing.ImageIcon combine(javax.swing.ImageIcon a_one, javax.swing.ImageIcon a_two)
a_one
- an ImageIcona_two
- another ImageIcon
public static void setLocationRelativeTo(java.awt.Component a_component, java.awt.Window a_movedWindow)
public static java.awt.Window getParentWindow(java.awt.Component a_component)
a_component
- a Component
public static void positionRightUnderWindow(java.awt.Window a_window, java.awt.Window a_parent)
a_window
- a Windowa_parent
- the Window's parent windowpublic static void moveToUpRightCorner(java.awt.Window a_window)
a_window
- a Windowpublic static void setNativeGUILibrary(GUIUtils.NativeGUILibrary a_library)
public static boolean isAlwaysOnTop(java.awt.Component a_component)
public static boolean isAlwaysOnTop(java.awt.Window a_Window)
a_Window
- a Window
public static void setFontStyle(java.awt.Component a_component, int a_style)
public static boolean setAlwaysOnTop(java.awt.Component a_component, boolean a_bOnTop)
public static boolean hasJavaOnTop()
public static boolean setAlwaysOnTop(java.awt.Window a_Window, boolean a_bOnTop)
a_Window
- Windowa_bOnTop
- boolean
public static boolean restoreSize(java.awt.Window a_window, java.awt.Dimension a_size)
a_window
- Windowa_size
- Dimension
public static java.awt.Point getMiddlePoint(java.awt.Window a_window)
public static boolean restoreLocation(java.awt.Window a_window, java.awt.Point a_location)
a_window
- Windowa_location
- Point
public static java.awt.event.MouseListener addTimedTooltipListener(javax.swing.JComponent c)
public static GUIUtils.Screen[] getScreens(java.awt.Window a_window)
public static GUIUtils.Screen getCurrentScreen(java.awt.Component a_component)
public static GUIUtils.Screen getCurrentScreen(java.awt.Window a_window)
public static void centerOnScreen(java.awt.Window a_window)
a_window
- a Windowpublic static void centerOnWindow(java.awt.Window a_window, java.awt.Window a_parent)
a_window
- a Windowa_parent
- the Window's parent windowpublic static javax.swing.JTextPane createSelectableAndResizeableLabel(java.awt.Component a_parent)
a_parent
- Component
public static javax.swing.JLabel createMultiLineLabel(java.lang.String messageKey, int width)
messageKey
- key of the messagewidth
- of the label to enforce line breaks.
public static javax.swing.JLabel createLabel(java.lang.String messageKey)
messageKey
- key of the message
public static javax.swing.JLabel createLabel(java.lang.String messageKey1, java.lang.String messageKey2)
messageKey1
- key of the first messagemessageKey2
- key of the second message
public static javax.swing.JButton createButton(java.lang.String messageKey)
public static javax.swing.JLabel createLabel(java.lang.String[] messageKeys)
messageKeys
- keys to the messages that shall be displayed by a JLabel
public static boolean isMouseButton(java.awt.event.MouseEvent a_event, int a_buttonMask)
a_event
- a MouseEventa_buttonMask
- a button mask from MouseEvent
MouseEvent
public static java.awt.datatransfer.Clipboard getSystemClipboard()
public static java.util.Vector registerLookAndFeelClasses(java.io.File a_file) throws java.lang.IllegalAccessException
java.lang.IllegalAccessException
public static void resizeAllFonts(float a_resize)
a_resize
- the factor to resize the fontspublic static java.lang.String getTextFromClipboard(java.awt.Component a_requestingComponent)
public static void saveTextToClipboard(java.lang.String strText, java.awt.Component a_requestingComponent)
public static javax.swing.ImageIcon createScaledImageIcon(javax.swing.ImageIcon a_icon, GUIUtils.IIconResizer a_resizer)
public static javax.swing.Icon createScaledIcon(javax.swing.Icon a_icon, GUIUtils.IIconResizer a_resizer)
public static java.lang.String trim(java.lang.String a_strOriginal, int a_maximumLength)
a_strOriginal
- Stringa_maximumLength
- the maximum length that is displayed
public static java.lang.String trim(java.lang.String a_strOriginal)
a_strOriginal
- String
public static void addAWTEventListener(GUIUtils.AWTEventListener a_listener)
public static void removeAWTEventListener(GUIUtils.AWTEventListener a_listener)
public static java.awt.Point getMousePosition()
public static java.awt.Point getRelativePosition(java.awt.Point a_positionOnScreen, java.awt.Component a_component)
public static java.awt.Point getMousePosition(java.awt.Component a_component)
private static GUIUtils.Screen getOverlappingScreen(GUIUtils.Screen a_screen, java.awt.Window a_window)
a_screen
- Screena_window
- Window
private static java.lang.String getTextFromClipboard(java.awt.Component a_requestingComponent, boolean a_bUseTextArea)
private static java.awt.Rectangle getDefaultScreenBounds(java.awt.Window a_window)
a_window
- a Window
private static void adjustFontSize(java.lang.Object a_fontObject, float a_resize)
a_fontObject
- a UIManager font objecta_resize
- the factor to resize the given fontpublic static java.awt.Dimension getMaxSize(java.util.Vector aComponents)
aComponents
- Vector
public static java.awt.Dimension getTotalSize(java.util.Vector aComponents)
aComponents
- Vector
public static int showMonitoredFileChooser(javax.swing.JFileChooser a_chooser, java.awt.Component a_parent)
a_chooser
- a file choosera_parent
- the parent component over which the file chooser should be displayed
public static void setSizes(java.util.Vector aComponents, java.awt.Dimension aDimension)
aComponents
- VectoraDimension
- Dimensionpublic static void setEqualWidths(java.util.Vector aComponents, java.awt.Dimension aDimension)
aComponents
- VectoraDimension
- Dimensionpublic static void exitWithNoMessagesError(java.lang.String a_resourceBundleFilename)
public static java.lang.String getCountryFromServiceLocation(ServiceLocation a_loc)
private static void interruptAWTEventThread()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |