org.fuin.utils4swing.common
Class Utils4Swing

java.lang.Object
  extended by org.fuin.utils4swing.common.Utils4Swing

public final class Utils4Swing
extends java.lang.Object

Common utility methods for use in Swing applications and libraries.


Nested Class Summary
static class Utils4Swing.GlassPaneState
           
 
Method Summary
static void addToClasspath(java.lang.String url)
          Adds an URL to the classpath.
static void addToClasspath(java.net.URL url)
          Adds an URL to the classpath.
static boolean containsURL(java.net.URL[] urls, java.net.URL url)
          Checks if the array or URLs contains the given URL.
static java.lang.Object createInstance(java.lang.String className)
          Create an instance with Class.forName(..) and wrap all exceptions into RuntimeExceptions.
static javax.swing.JFrame createShowAndPosition(java.lang.String title, java.awt.Container content, boolean exitOnClose, boolean resizable, FramePositioner positioner)
           
static javax.swing.JFrame createShowAndPosition(java.lang.String title, java.awt.Container content, boolean exitOnClose, FramePositioner positioner)
          Create a new resizeable frame with a panel as it's content pane and position the frame.
static javax.swing.RootPaneContainer findRootPaneContainer(java.awt.Component source)
          Find the root pane container in the current hierarchy.
static java.lang.String getPackagePath(java.lang.Class clasz)
          Returns the package path of a class.
static java.net.URL getResource(java.lang.Class clasz, java.lang.String name)
          Get the path to a resource located in the same package as a given class.
static void hideGlassPane(Utils4Swing.GlassPaneState state)
           
static void initLookAndFeel(java.lang.String className)
          Initializes the look and feel and wraps exceptions into a runtime exception.
static void initSystemLookAndFeel()
          Initializes the system look and feel and wraps exceptions into a runtime exception.
static javax.swing.ImageIcon loadIcon(java.lang.Class clasz, java.lang.String name)
          Load an icon located in the same package as a given class.
static Utils4Swing.GlassPaneState showGlassPane(java.awt.Component source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createShowAndPosition

public static javax.swing.JFrame createShowAndPosition(java.lang.String title,
                                                       java.awt.Container content,
                                                       boolean exitOnClose,
                                                       FramePositioner positioner)
Create a new resizeable frame with a panel as it's content pane and position the frame.

Parameters:
title - Frame title.
content - Content.
exitOnClose - Exit the program on closing the frame?
positioner - FramePositioner.
Returns:
A visible frame at the preferred position.

createShowAndPosition

public static javax.swing.JFrame createShowAndPosition(java.lang.String title,
                                                       java.awt.Container content,
                                                       boolean exitOnClose,
                                                       boolean resizable,
                                                       FramePositioner positioner)
Parameters:
title - Frame title.
content - Content.
exitOnClose - Exit the program on closing the frame?
resizable - If the frame should be resizeable TRUE else FALSE.
positioner - FramePositioner.
Returns:
A visible frame at the preferred position.

getPackagePath

public static java.lang.String getPackagePath(java.lang.Class clasz)
Returns the package path of a class.

Parameters:
clasz - Class to determine the path for.
Returns:
Package path for the class.

getResource

public static java.net.URL getResource(java.lang.Class clasz,
                                       java.lang.String name)
Get the path to a resource located in the same package as a given class.

Parameters:
clasz - Class with the same package where the resource is located.
name - Filename of the resource.
Returns:
Resource URL.

loadIcon

public static javax.swing.ImageIcon loadIcon(java.lang.Class clasz,
                                             java.lang.String name)
Load an icon located in the same package as a given class.

Parameters:
clasz - Class with the same package where the icon is located.
name - Filename of the icon.
Returns:
New icon instance.

initLookAndFeel

public static void initLookAndFeel(java.lang.String className)
Initializes the look and feel and wraps exceptions into a runtime exception.

Parameters:
className - Full qualified name of the look and feel class.

initSystemLookAndFeel

public static void initSystemLookAndFeel()
Initializes the system look and feel and wraps exceptions into a runtime exception.


createInstance

public static java.lang.Object createInstance(java.lang.String className)
Create an instance with Class.forName(..) and wrap all exceptions into RuntimeExceptions.

Parameters:
className - Full qualified class name.
Returns:
New instance of the class.

addToClasspath

public static void addToClasspath(java.lang.String url)
Adds an URL to the classpath.

Parameters:
url - URL to add.

containsURL

public static boolean containsURL(java.net.URL[] urls,
                                  java.net.URL url)
Checks if the array or URLs contains the given URL.

Parameters:
urls - Array of URLs.
url - URL to find.
Returns:
If the URL is in the array TRUE else FALSE.

addToClasspath

public static void addToClasspath(java.net.URL url)
Adds an URL to the classpath.

Parameters:
url - URL to add.

findRootPaneContainer

public static javax.swing.RootPaneContainer findRootPaneContainer(java.awt.Component source)
Find the root pane container in the current hierarchy.

Parameters:
source - Component to start with.
Returns:
Root pane container or NULL if it cannot be found.

showGlassPane

public static Utils4Swing.GlassPaneState showGlassPane(java.awt.Component source)

hideGlassPane

public static void hideGlassPane(Utils4Swing.GlassPaneState state)


Copyright © 2009 Future Invent Informationsmanagement GmbH. All Rights Reserved.