org.esa.beam.framework.ui
Class UIUtils

java.lang.Object
  extended by org.esa.beam.framework.ui.UIUtils

public class UIUtils
extends Object

The UIUtils class provides methods frequently used in connection with graphical user interfaces.

Version:
$Revision: 8407 $ $Date: 2010-02-14 12:58:02 +0100 (So, 14 Feb 2010) $
Author:
Norman Fomferra

Field Summary
static Color COLOR_DARK_BLUE
           
static Color COLOR_DARK_GREEN
           
static Color COLOR_DARK_RED
           
static String IMAGE_RESOURCE_PATH
           
 
Method Summary
static void centerComponent(Component comp)
          Centers the given component within the screen area.
static void centerComponent(Component comp, Component alignComp)
          Centers the given component over another component.
static JSpinner createDoubleSpinner(double value, double rangeMinimum, double rangeMaximum, double stepSize, double bigStepSize, String formatPattern)
           
static Border createGroupBorder(String title)
           
static JSpinner createSpinner(Number value, Comparable rangeMinimum, Comparable rangeMaximum, Number stepSize, Number bigStepSize, String formatPattern)
           
static JSpinner createSpinner(Parameter param, Number spinnerStep, String formatPattern)
           
static JMenu findMenu(JMenuBar menuBar, String name, boolean deepSearch)
           
static int findMenuItemPosition(JPopupMenu popupMenu, String name)
           
static JMenu findSubMenu(JPopupMenu popupMenu, String name)
           
static URL getImageURL(String resourcePath)
          Gets the location of the given image resource path as an URL.
static URL getImageURL(String resourcePath, Class callerClass)
          Gets the location of the given image resource path as an URL.
static Frame getRootFrame(Component component)
           
static JFrame getRootJFrame(Component component)
           
static Window getRootWindow(Component component)
           
static int getScreenHeight()
          Returns the (main) screen's height in pixels.
static Dimension getScreenSize()
          Returns the (main) screen's size in pixels.
static int getScreenWidth()
          Returns the (main) screen's width in pixels.
static String getUniqueFrameTitle(JInternalFrame[] frames, String titleBase)
           
static ImageIcon loadImageIcon(String resourcePath)
          Gets the image icon loaded from the given resource path.
static ImageIcon loadImageIcon(String resourcePath, Class callerClass)
          Gets the image icon loaded from the given resource path.
static Cursor setRootFrameCursor(Component component, Cursor newCursor)
           
static Cursor setRootFrameDefaultCursor(Component component)
           
static Cursor setRootFrameWaitCursor(Component component)
           
static void showPopup(JPopupMenu popup, MouseEvent event)
          Ensures that the popup menue is allways inside the application frame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAGE_RESOURCE_PATH

public static final String IMAGE_RESOURCE_PATH
See Also:
Constant Field Values

COLOR_DARK_RED

public static final Color COLOR_DARK_RED

COLOR_DARK_BLUE

public static final Color COLOR_DARK_BLUE

COLOR_DARK_GREEN

public static final Color COLOR_DARK_GREEN
Method Detail

loadImageIcon

public static ImageIcon loadImageIcon(String resourcePath)
Gets the image icon loaded from the given resource path.

Note that this method only works for images found in the classpath of the class loader which loaded this UIUtils class. If you are not sure, you should better use getImageURL(String, Class).

Parameters:
resourcePath - the resource path
Returns:
an image icon loaded from the given resource path or null if it could not be found

loadImageIcon

public static ImageIcon loadImageIcon(String resourcePath,
                                      Class callerClass)
Gets the image icon loaded from the given resource path.

Parameters:
resourcePath - the resource path
callerClass - the class which calls this method and therefore provides the class loader for the requested resource
Returns:
an image icon loaded from the given resource path or null if it could not be found
Since:
4.0

getImageURL

public static URL getImageURL(String resourcePath)
Gets the location of the given image resource path as an URL.

Note that this method only works for images found in the classpath of the class loader which loaded this UIUtils class. If you are not sure, you should better use getImageURL(String, Class).

Parameters:
resourcePath - the resource path
Returns:
an URL representing the given resource path or null if it could not be found

getImageURL

public static URL getImageURL(String resourcePath,
                              Class callerClass)
Gets the location of the given image resource path as an URL.

Parameters:
resourcePath - the resource path
callerClass - the class which calls this method and therefore provides the class loader for the requested resource
Returns:
an URL representing the given resource path or null if it could not be found
Since:
4.0

getScreenSize

public static Dimension getScreenSize()
Returns the (main) screen's size in pixels.


getScreenWidth

public static int getScreenWidth()
Returns the (main) screen's width in pixels.


getScreenHeight

public static int getScreenHeight()
Returns the (main) screen's height in pixels.


centerComponent

public static void centerComponent(Component comp)
Centers the given component within the screen area.

The method performs the alignment by setting a newly computed location for the component. It does not alter the component's size.

Parameters:
comp - the component whose location is to be altered
Throws:
IllegalArgumentException - if the component is null

centerComponent

public static void centerComponent(Component comp,
                                   Component alignComp)
Centers the given component over another component.

The method performs the alignment by setting a newly computed location for the component. It does not alter the component's size.

Parameters:
comp - the component whose location is to be altered
alignComp - the component used for the alignment of the first component, if null the component is ceneterd within the screen area
Throws:
IllegalArgumentException - if the component is null

showPopup

public static void showPopup(JPopupMenu popup,
                             MouseEvent event)
Ensures that the popup menue is allways inside the application frame


getRootWindow

public static Window getRootWindow(Component component)

createGroupBorder

public static Border createGroupBorder(String title)

getRootFrame

public static Frame getRootFrame(Component component)

getRootJFrame

public static JFrame getRootJFrame(Component component)

setRootFrameWaitCursor

public static Cursor setRootFrameWaitCursor(Component component)

setRootFrameDefaultCursor

public static Cursor setRootFrameDefaultCursor(Component component)

setRootFrameCursor

public static Cursor setRootFrameCursor(Component component,
                                        Cursor newCursor)

findMenu

public static JMenu findMenu(JMenuBar menuBar,
                             String name,
                             boolean deepSearch)

findMenuItemPosition

public static int findMenuItemPosition(JPopupMenu popupMenu,
                                       String name)

findSubMenu

public static JMenu findSubMenu(JPopupMenu popupMenu,
                                String name)

getUniqueFrameTitle

public static String getUniqueFrameTitle(JInternalFrame[] frames,
                                         String titleBase)

createSpinner

public static JSpinner createSpinner(Parameter param,
                                     Number spinnerStep,
                                     String formatPattern)

createDoubleSpinner

public static JSpinner createDoubleSpinner(double value,
                                           double rangeMinimum,
                                           double rangeMaximum,
                                           double stepSize,
                                           double bigStepSize,
                                           String formatPattern)

createSpinner

public static JSpinner createSpinner(Number value,
                                     Comparable rangeMinimum,
                                     Comparable rangeMaximum,
                                     Number stepSize,
                                     Number bigStepSize,
                                     String formatPattern)


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.