Task.Support.GUISupport
Class GUIUtils

java.lang.Object
  extended by Task.Support.GUISupport.GUIUtils

public class GUIUtils
extends java.lang.Object

GUIUtils is a utility class with frequently used functions to make writing Swing GUI apps easier

Since:
Jan 6, 2007, 7:29:25 PM
Author:
Nazmul Idris

Method Summary
static void addToSystemTray(java.awt.TrayIcon icon)
           
static java.lang.String applyBoldTag(java.lang.String msg)
           
static java.lang.String applyCenterTag(java.lang.String msg)
           
static java.lang.String applyFontColorTag(java.lang.String msg)
           
static java.lang.String applyFontColorTag(java.lang.String msg, Colors color)
           
static java.lang.String applyItalicTag(java.lang.String msg)
           
static java.lang.String applyUnderlineTag(java.lang.String msg)
           
static void centerOnScreen(javax.swing.JFrame frame)
           
protected static java.awt.image.BufferedImage createFDImage()
           
static void enableDynamicLayout()
           
static java.lang.String encloseWithTag(java.lang.String msg, java.lang.String tag)
           
static java.lang.String encloseWithTag(java.lang.String startTag, java.lang.String msg, java.lang.String endTag)
           
static java.lang.String formatForLabel(java.lang.String msg)
           
static java.lang.String getFormattedTooltip(java.lang.String header, java.lang.String description)
          Return an HTML formatted tooltip string similar to what Office 2007 has.
static java.awt.TrayIcon getSystemTrayIcon(java.awt.image.BufferedImage img)
           
static java.awt.TrayIcon getSystemTrayIcon(java.lang.String iconName)
          create a trayicon with the provided image
static java.awt.Rectangle getWindowBoundsFromPersistence(java.lang.Class myclass)
          the first time this method is called, and there are no prefs stored in the registry, it will return null
static boolean isEmptyOrNull(java.lang.String msg)
           
static boolean isSystemTrayAvailable()
           
static void launchExternalBrowser(java.lang.String url)
           
static java.lang.String makeLabelWithShortcut(java.lang.String labelText, int keybAccel)
           
static char mnemonicToString(int mnemonic)
          Converts the KeyEvent int to a String that can be displayed in a UI.
static void putWindowBoundsToPersistence(java.lang.Class myclass, java.awt.Rectangle bounds)
           
static void removeFromSystemTray(java.awt.TrayIcon icon)
          Warning: Don't call this method from a VM shutdown hook thread. it causes deadlock for some reason?!
static void setAppIcon(javax.swing.JFrame frame, java.awt.Image image)
           
static void setAppIcon(javax.swing.JFrame frame, java.lang.String image)
           
static void setMinimumWindowSize(javax.swing.JFrame frame, java.awt.Dimension d)
           
static void setMinimumWindowSize(javax.swing.JFrame frame, int w, int h)
           
static void setNimbusLookAndFeelBeforeUIStarted()
           
static void setSystemLookAndFeel(javax.swing.JFrame frame)
           
static void setSystemLookAndFeelBeforeUIStarted()
           
static void setUIDefaultColorProperty(java.lang.String colorProp, java.awt.Color color)
          uses UIDefault to replace a color property
static void setUIDefaultFontProperty(java.lang.String fontProp, java.awt.Font font)
          uses UIDefault to replace a font property
static void showErrorDialog(java.awt.Component parentComponent, java.lang.String msg)
           
static void showErrorDialog(java.awt.Component parentComponent, java.lang.String msg, java.lang.Throwable ex)
           
static void showErrorDialog(java.awt.Component parentComponent, java.lang.Throwable ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

mnemonicToString

public static char mnemonicToString(int mnemonic)
                             throws java.lang.IllegalArgumentException
Converts the KeyEvent int to a String that can be displayed in a UI. Used to generate Alt + "?" in labels. Swing components store the keyboard accelerators as ints (KeyEvent.VK_XXX).

Throws:
java.lang.IllegalArgumentException
See Also:
AbstractButton.setMnemonic(char)

formatForLabel

public static java.lang.String formatForLabel(java.lang.String msg)

makeLabelWithShortcut

public static java.lang.String makeLabelWithShortcut(java.lang.String labelText,
                                                     int keybAccel)

encloseWithTag

public static java.lang.String encloseWithTag(java.lang.String msg,
                                              java.lang.String tag)

encloseWithTag

public static java.lang.String encloseWithTag(java.lang.String startTag,
                                              java.lang.String msg,
                                              java.lang.String endTag)

applyFontColorTag

public static java.lang.String applyFontColorTag(java.lang.String msg,
                                                 Colors color)

applyFontColorTag

public static java.lang.String applyFontColorTag(java.lang.String msg)

applyCenterTag

public static java.lang.String applyCenterTag(java.lang.String msg)

applyItalicTag

public static java.lang.String applyItalicTag(java.lang.String msg)

applyBoldTag

public static java.lang.String applyBoldTag(java.lang.String msg)

applyUnderlineTag

public static java.lang.String applyUnderlineTag(java.lang.String msg)

getFormattedTooltip

public static java.lang.String getFormattedTooltip(java.lang.String header,
                                                   java.lang.String description)
Return an HTML formatted tooltip string similar to what Office 2007 has. Here's a sample:
   Paste (Ctrl+V)         <- Bold + Black
   Pastes the contents of <- Dark Gray & multi-line
   the Clipboard
 


setUIDefaultFontProperty

public static void setUIDefaultFontProperty(java.lang.String fontProp,
                                            java.awt.Font font)
uses UIDefault to replace a font property


setUIDefaultColorProperty

public static void setUIDefaultColorProperty(java.lang.String colorProp,
                                             java.awt.Color color)
uses UIDefault to replace a color property


setSystemLookAndFeelBeforeUIStarted

public static final void setSystemLookAndFeelBeforeUIStarted()

setNimbusLookAndFeelBeforeUIStarted

public static final void setNimbusLookAndFeelBeforeUIStarted()

setSystemLookAndFeel

public static final void setSystemLookAndFeel(javax.swing.JFrame frame)
See Also:
Looks FAQ

enableDynamicLayout

public static void enableDynamicLayout()

isEmptyOrNull

public static final boolean isEmptyOrNull(java.lang.String msg)

showErrorDialog

public static final void showErrorDialog(java.awt.Component parentComponent,
                                         java.lang.String msg)

showErrorDialog

public static final void showErrorDialog(java.awt.Component parentComponent,
                                         java.lang.Throwable ex)

showErrorDialog

public static final void showErrorDialog(java.awt.Component parentComponent,
                                         java.lang.String msg,
                                         java.lang.Throwable ex)

centerOnScreen

public static final void centerOnScreen(javax.swing.JFrame frame)

setMinimumWindowSize

public static final void setMinimumWindowSize(javax.swing.JFrame frame,
                                              int w,
                                              int h)

setMinimumWindowSize

public static final void setMinimumWindowSize(javax.swing.JFrame frame,
                                              java.awt.Dimension d)

setAppIcon

public static final void setAppIcon(javax.swing.JFrame frame,
                                    java.lang.String image)

setAppIcon

public static final void setAppIcon(javax.swing.JFrame frame,
                                    java.awt.Image image)

isSystemTrayAvailable

public static final boolean isSystemTrayAvailable()

addToSystemTray

public static final void addToSystemTray(java.awt.TrayIcon icon)

removeFromSystemTray

public static final void removeFromSystemTray(java.awt.TrayIcon icon)
Warning: Don't call this method from a VM shutdown hook thread. it causes deadlock for some reason?!


getSystemTrayIcon

public static final java.awt.TrayIcon getSystemTrayIcon(java.lang.String iconName)
                                                 throws java.lang.UnsupportedOperationException
create a trayicon with the provided image

Parameters:
iconName - this is the name of an image file that will be loaded with ImageUtils (from the classpath)
Throws:
java.lang.UnsupportedOperationException - - if SystemTrays are not supported on this platform...

getSystemTrayIcon

public static final java.awt.TrayIcon getSystemTrayIcon(java.awt.image.BufferedImage img)
                                                 throws java.lang.UnsupportedOperationException
Throws:
java.lang.UnsupportedOperationException

createFDImage

protected static java.awt.image.BufferedImage createFDImage()

launchExternalBrowser

public static void launchExternalBrowser(java.lang.String url)

putWindowBoundsToPersistence

public static void putWindowBoundsToPersistence(java.lang.Class myclass,
                                                java.awt.Rectangle bounds)

getWindowBoundsFromPersistence

public static java.awt.Rectangle getWindowBoundsFromPersistence(java.lang.Class myclass)
the first time this method is called, and there are no prefs stored in the registry, it will return null



Copyright © 2011. All Rights Reserved.