net.sourceforge.atunes.gui
Class GuiUtils

java.lang.Object
  extended by net.sourceforge.atunes.gui.GuiUtils

public class GuiUtils
extends java.lang.Object

GUI related utility methods.


Constructor Summary
GuiUtils()
           
 
Method Summary
static void addCloseActionWithEscapeKey(javax.swing.JDialog dialog)
          Adds the close action with escape key.
static void addCloseActionWithEscapeKey(javax.swing.JFrame frame)
          Adds the close action with escape key.
static void addDisposeActionWithEscapeKey(javax.swing.JDialog dialog)
          Adds the dispose action with escape key.
static void addDisposeActionWithEscapeKey(javax.swing.JFrame frame)
          Adds the dispose action with escape key.
static void applyComponentOrientation(java.awt.Container... containers)
          Applies Locale specific component orientation to containers.
static void collapseTree(javax.swing.JTree tree)
          Collapses all nodes in a tree.
static void expandTree(javax.swing.JTree tree)
          Expands all nodes in a tree.
static java.awt.Color getBackgroundColor()
          Returns background color for panels, as set by Look And Feel.
static java.awt.Color getBorderColor()
          Returns border color for panels, based on background color.
static int getComponentHeightForResolution(int screenHeight, int desiredHeight)
          Returns a proportional height according to screenHeight and desiredHeight for the current screen resolution.
static java.awt.ComponentOrientation getComponentOrientation()
          Returns the component orientation.
static int getComponentOrientationAsSwingConstant()
          Returns the component orientation as a SwingConstant.
static int getComponentWidthForResolution(int screenWidth, int desiredWidth)
          Returns a proportional width according to screenWidth and desiredSize for the current screen resolution.
static int getDeviceHeight()
          Returns the height in pixels of the main device
static int getDeviceWidth()
          Returns the width in pixels of the main device
static java.awt.Color getForegroundColor()
          Returns foreground color for labels, as set by Look And Feel
static void setBorderColor(java.awt.Color borderColor)
          Sets the border color.
static void setLocation(java.awt.Window window)
          Sets location of a window centered in main screen device.
static void setUIFont(javax.swing.plaf.FontUIResource f)
          Sets the default font for all Swing components.
static void setWindowOpacity(java.awt.Window window, float opacity)
          Sets the window opacity if possible.
static void setWindowOpaque(java.awt.Window window, boolean opaque)
          Sets the window opaque if possible.
static void setWindowShape(java.awt.Window window, java.awt.Shape mask)
          Sets the window shape if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuiUtils

public GuiUtils()
Method Detail

getDeviceWidth

public static int getDeviceWidth()
Returns the width in pixels of the main device

Returns:

getDeviceHeight

public static int getDeviceHeight()
Returns the height in pixels of the main device

Returns:

setLocation

public static void setLocation(java.awt.Window window)
Sets location of a window centered in main screen device. Window must have size different of (0,0)

Parameters:
window -

addCloseActionWithEscapeKey

public static void addCloseActionWithEscapeKey(javax.swing.JDialog dialog)
Adds the close action with escape key.

Parameters:
dialog - the dialog

addCloseActionWithEscapeKey

public static void addCloseActionWithEscapeKey(javax.swing.JFrame frame)
Adds the close action with escape key.

Parameters:
frame - the frame

addDisposeActionWithEscapeKey

public static void addDisposeActionWithEscapeKey(javax.swing.JDialog dialog)
Adds the dispose action with escape key.

Parameters:
dialog - the dialog

addDisposeActionWithEscapeKey

public static void addDisposeActionWithEscapeKey(javax.swing.JFrame frame)
Adds the dispose action with escape key.

Parameters:
frame - the frame

applyComponentOrientation

public static void applyComponentOrientation(java.awt.Container... containers)
Applies Locale specific component orientation to containers.

Parameters:
containers - One or more containers

collapseTree

public static void collapseTree(javax.swing.JTree tree)
Collapses all nodes in a tree.

Parameters:
tree - the tree

expandTree

public static void expandTree(javax.swing.JTree tree)
Expands all nodes in a tree.

Parameters:
tree - A tree

getBackgroundColor

public static java.awt.Color getBackgroundColor()
Returns background color for panels, as set by Look And Feel.

Returns:
the background color

getForegroundColor

public static java.awt.Color getForegroundColor()
Returns foreground color for labels, as set by Look And Feel

Returns:
the forefround color

getBorderColor

public static java.awt.Color getBorderColor()
Returns border color for panels, based on background color.

Returns:
the border color

getComponentOrientation

public static java.awt.ComponentOrientation getComponentOrientation()
Returns the component orientation.

Returns:
The component orientation

getComponentOrientationAsSwingConstant

public static int getComponentOrientationAsSwingConstant()
Returns the component orientation as a SwingConstant.

Returns:
The component orientation as a SwingConstant

getComponentWidthForResolution

public static int getComponentWidthForResolution(int screenWidth,
                                                 int desiredWidth)
Returns a proportional width according to screenWidth and desiredSize for the current screen resolution.

Parameters:
screenWidth - the screen width
desiredWidth - the desired width
Returns:
the component width for resolution

getComponentHeightForResolution

public static int getComponentHeightForResolution(int screenHeight,
                                                  int desiredHeight)
Returns a proportional height according to screenHeight and desiredHeight for the current screen resolution.

Parameters:
screenHeight - the screen height
desiredHeight - the desired height
Returns:
the component height for resolution

setBorderColor

public static void setBorderColor(java.awt.Color borderColor)
Sets the border color.

Parameters:
borderColor - the borderColor to set

setUIFont

public static void setUIFont(javax.swing.plaf.FontUIResource f)
Sets the default font for all Swing components.

Parameters:
f - the f

setWindowShape

public static void setWindowShape(java.awt.Window window,
                                  java.awt.Shape mask)
Sets the window shape if possible.

Parameters:
window - A mindow
mask - A mask

setWindowOpacity

public static void setWindowOpacity(java.awt.Window window,
                                    float opacity)
Sets the window opacity if possible.

Parameters:
window - A window
opacity - Opacity from 0 to 1

setWindowOpaque

public static void setWindowOpaque(java.awt.Window window,
                                   boolean opaque)
Sets the window opaque if possible.

Parameters:
window - A window
opaque - If the window should be opaque


Copyright © 2006-2008 The aTunes Team. All Rights Reserved.