Groovy Documentation

griffon.swing
[Java] Class SwingUtils

java.lang.Object
  griffon.swing.SwingUtils

public class SwingUtils
extends Object

Additional utilities for Swing based applications.

Authors:
Andres Almiray
Since:
0.3.1


Constructor Summary
SwingUtils()

 
Method Summary
static void centerOnScreen(Window window)

Centers a Window on the screen

static void centerOnScreen(JInternalFrame internalFrame)

Centers a JInternalFrame on the screen

static Window createApplicationFrame(GriffonApplication app)

Creates a Window based on the application's configuration.

static Component findComponentByName(String name, Container root)

Searches a component by name in a particular component hierarchy.

static float getWindowOpacity(Window window)

Returns the window's current opacity value.

static boolean isTranslucencySupported()

Finds out if translucency is supported by the current platform.

private static Class loadClass(String className)

static void setWindowOpacity(Window window, float opacity)

Sets the value for the window's opacity.

static Image takeSnapshot(Component component)

Takes a snapshot of the target component.

static Image takeSnapshot(Component component, boolean usePrint)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Constructor Detail

SwingUtils

SwingUtils()


 
Method Detail

centerOnScreen

public static void centerOnScreen(Window window)
Centers a Window on the screen

Sets the window on the top left corner if the window's dimensions are bigger than the screen's.

Parameters:
window - a Window object


centerOnScreen

public static void centerOnScreen(JInternalFrame internalFrame)
Centers a JInternalFrame on the screen

Sets the internal frame on the top left corner if the frame's dimensions are bigger than the desktop's.

Parameters:
internalFrame - a JInternalFrame object


createApplicationFrame

public static Window createApplicationFrame(GriffonApplication app)
Creates a Window based on the application's configuration.

Class lookup order is

  1. value in app.config.application.frameClass
  2. 'org.jdesktop.swingx.JXFrame' if SwingX is in the classpath
  3. 'javax.swing.JFrame'
  4. Parameters:
    app - the current running application
    Returns:
    a newly instantiated window according to the application's preferences


findComponentByName

public static Component findComponentByName(String name, Container root)
Searches a component by name in a particular component hierarchy.

A component must have a value for its name property if it's to be found with this method.
This method performs a depth-first search.

Parameters:
name - the value of the component's name property
root - the root of the component hierarchy from where searching searching should start
Returns:
the component reference if found, null otherwise


getWindowOpacity

public static float getWindowOpacity(Window window)
Returns the window's current opacity value.
Parameters:
window - the window on which the opacity will be queried
Returns:
the window's opacity value


isTranslucencySupported

public static boolean isTranslucencySupported()
Finds out if translucency is supported by the current platform.
Returns:
true if Translucency.TRANSLUCENT is supported, false otherwise


loadClass

private static Class loadClass(String className)


setWindowOpacity

public static void setWindowOpacity(Window window, float opacity)
Sets the value for the window's opacity.
Parameters:
window - the window on which the opacity will be set
opacity - the new opacity value


takeSnapshot

public static Image takeSnapshot(Component component)
Takes a snapshot of the target component.
Parameters:
component - the component to draw
Returns:
a Graphics compatible image of the component


takeSnapshot

public static Image takeSnapshot(Component component, boolean usePrint)


 

Groovy Documentation