Package utils
Class AWTUtils
java.lang.Object
utils.AWTUtils
Misc helper methods for AWT that don't require Thinlet.
- Author:
- Dirk Moebius
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGiven an AWTKeyStroke, returns a keystroke description that can be parsed byAWTKeyStroke.getAWTKeyStroke(String s).static DimensionReturns the dimension of the specified text string, if it would be rendered with the font and the rendering context of the specified component.static Stringstatic StringgetFontString(Font font) Returns a thinlet font description for the given font.static StringgetFontString(Font font, Font defaultFont) Returns a thinlet font description for the given font, containing only the font properties that differ from the given default font.static FrameGet the frame that the specified component resides in, or null if the component has no ancestor of typeFrame.static ImageLoad an icon.static ImageLoad an icon.static StringgetKeyText(int keyCode) Return the key description for a key code, according to the key names injava.awt.event.KeyEvent, omitting the prefix "VK_".
-
Constructor Details
-
AWTUtils
public AWTUtils()
-
-
Method Details
-
getColorString
-
getFontString
Returns a thinlet font description for the given font.- Parameters:
font- the font- Returns:
- a thinlet font description such as "Serif 10 bold italic"
-
getFontString
Returns a thinlet font description for the given font, containing only the font properties that differ from the given default font.- Parameters:
font- the fontdefaultFont- the default font- Returns:
- a thinlet font description such as "serif 10 bold italic"
-
getFrame
Get the frame that the specified component resides in, or null if the component has no ancestor of typeFrame. -
getBounds
Returns the dimension of the specified text string, if it would be rendered with the font and the rendering context of the specified component. -
getIcon
Load an icon. Use a MediaTracker synchronizing on the specified component to wait for the icon to load.- Parameters:
component- the component that the MediaTracker uses to control the loading of the icon.path- the path relative to the package path of the class of the component, e.g. "icons/icon.gif".
-
getIcon
Load an icon. Use a MediaTracker synchronizing on the specified component to wait for the icon to load.- Parameters:
component- the component that the MediaTracker uses to control the loading of the icon.url- the URL of the icon.
-
getAWTKeyStrokeDescription
Given an AWTKeyStroke, returns a keystroke description that can be parsed byAWTKeyStroke.getAWTKeyStroke(String s).Examples: "ctrl O", "alt shift F4", "altGraph Q"
-
getKeyText
Return the key description for a key code, according to the key names injava.awt.event.KeyEvent, omitting the prefix "VK_". For example the strings returned may be "A" - "Z", "F1" - "F24", "RIGHT", "BACK_SPACE", "DEAD_TILDE" and so on.- Parameters:
keyCode-- Returns:
-