Enhydra 5.1 API

org.enhydra.tool.common
Class SwingUtil

java.lang.Object
  |
  +--org.enhydra.tool.common.SwingUtil

public class SwingUtil
extends java.lang.Object

SwingUtil contains static utility methods for working with Swing classes.


Method Summary
static java.awt.Point getCenteringPoint(java.awt.Dimension size)
          Get the point on point on the screen at which to open a dialog or window for it to appear centered.
static java.io.File getDirectoryChoice(java.awt.Component owner, java.io.File defaultDir, java.lang.String title)
          Open a JFileChooser dialog for selecting a directory and return the selected directory.
static java.io.File getDirectoryChoice(java.awt.Component owner, java.lang.String defaultDir, java.lang.String title)
          Open a JFileChooser dialog for selecting a directory and return the selected directory.
static java.io.File getFileChoice(java.awt.Component owner, java.io.File defaultSelection, javax.swing.filechooser.FileFilter filter, java.lang.String title)
          Get a file selection using the FileChooser dialog.
static java.io.File getFileChoice(java.awt.Component owner, java.lang.String defaultSelection, javax.swing.filechooser.FileFilter filter, java.lang.String title)
          Get a file selection using the FileChooser dialog.
static void setLookAndFeelToSystem()
          Sets the look and feel to the native operating system look and feel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDirectoryChoice

public static java.io.File getDirectoryChoice(java.awt.Component owner,
                                              java.lang.String defaultDir,
                                              java.lang.String title)
Open a JFileChooser dialog for selecting a directory and return the selected directory.

Parameters:
owner - The frame or dialog that controls the invokation of this dialog.
defaultDir - A string representation of the directory to show when the dialog opens.
title - Tile for the dialog.
Returns:
The selected directory as a File. Null if user cancels dialog without a selection.

getDirectoryChoice

public static java.io.File getDirectoryChoice(java.awt.Component owner,
                                              java.io.File defaultDir,
                                              java.lang.String title)
Open a JFileChooser dialog for selecting a directory and return the selected directory.

Parameters:
owner - The frame or dialog that controls the invokation of this dialog.
defaultDir - The directory to show when the dialog opens.
title - Tile for the dialog.
Returns:
The selected directory as a File. Null if user cancels dialog without a selection.

getFileChoice

public static java.io.File getFileChoice(java.awt.Component owner,
                                         java.lang.String defaultSelection,
                                         javax.swing.filechooser.FileFilter filter,
                                         java.lang.String title)
Get a file selection using the FileChooser dialog.

Parameters:
owner - The parent of this modal dialog.
defaultSelection - The default file selection as a string.
filter - An extension filter
title - The caption for the dialog.
Returns:
A selected file or null if no selection is made.

getFileChoice

public static java.io.File getFileChoice(java.awt.Component owner,
                                         java.io.File defaultSelection,
                                         javax.swing.filechooser.FileFilter filter,
                                         java.lang.String title)
Get a file selection using the FileChooser dialog.

Parameters:
owner - The parent of this modal dialog.
defaultSelection - The default file selection as a file.
filter - An extension filter
title - The caption for the dialog.
Returns:
A selected file or null if no selection is made.

getCenteringPoint

public static java.awt.Point getCenteringPoint(java.awt.Dimension size)
Get the point on point on the screen at which to open a dialog or window for it to appear centered. This point is the top right hand corner of the container you want to position.

Parameters:
size - The demensions of the dialog or window to position.
Returns:
The top left hand point at which to position the container for it to appear centered.

setLookAndFeelToSystem

public static void setLookAndFeelToSystem()
Sets the look and feel to the native operating system look and feel. This method ignores any exceptions that may occur when you set the look and feel.


Enhydra 5.1 API