org.geotools.resources
Class SwingUtilities

java.lang.Object
  extended byorg.geotools.resources.SwingUtilities

public final class SwingUtilities
extends java.lang.Object

A collection of utility methods for Swing. All show* methods delegate their work to the corresponding method in JOptionPane, with two differences:

Since:
2.0
Version:
$Id: SwingUtilities.java 17890 2006-02-06 08:46:14Z desruisseaux $
Author:
Martin Desruisseaux

Method Summary
static java.util.Locale getLocale(java.awt.Component component)
          Returns the locale for the specified component, or a default one if the component is not yet part of a container hierarchy.
static javax.swing.JComponent getMultilineLabelFor(javax.swing.JComponent owner, java.lang.String text)
          Retourne une ?tiquette pour la composante sp?cifi?e.
static void invokeAndWait(java.lang.Runnable runnable)
          Causes runnable to have its run method called in the dispatch thread of the event queue.
static void setTitle(java.awt.Component component, java.lang.String title)
          Set the title of the parent frame or internal frame of the specified component.
static boolean showConfirmDialog(java.awt.Component owner, java.lang.Object message, java.lang.String title, int type)
          Brings up a confirmation dialog with "Yes/No" buttons.
static void showMessageDialog(java.awt.Component owner, java.lang.Object message, java.lang.String title, int type)
          Brings up a message dialog with a "Ok" button.
static boolean showOptionDialog(java.awt.Component owner, java.lang.Object dialog, java.lang.String title)
          Brings up a "Ok/Cancel" dialog with no icon.
static boolean showOptionDialog(java.awt.Component owner, java.lang.Object dialog, java.lang.String title, java.awt.event.ActionListener reset)
          Brings up a "Ok/Cancel/Reset" dialog with no icon.
static java.awt.Component toFrame(java.awt.Component owner, javax.swing.JComponent panel, java.lang.String title, java.awt.event.WindowListener listener)
          Insert a Swing component into a frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toFrame

public static java.awt.Component toFrame(java.awt.Component owner,
                                         javax.swing.JComponent panel,
                                         java.lang.String title,
                                         java.awt.event.WindowListener listener)
Insert a Swing component into a frame. The kind of frame depends on the owner:

Parameters:
owner - The frame's owner, or if none.
panel - The panel to insert into a frame.
title - The frame's title.
listener - A listener to receives frame events. If non-null, then this listener will be registered to whatever kind of frame this method will constructs. In the special case where this method constructs an internal frame and the is not an instance of InternalFrameListener, then this method will wrap the into an .
Returns:
The frame. This frame is not initially visible. The method must be invoked in order to show the frame.

setTitle

public static void setTitle(java.awt.Component component,
                            java.lang.String title)
Set the title of the parent frame or internal frame of the specified component.


showOptionDialog

public static boolean showOptionDialog(java.awt.Component owner,
                                       java.lang.Object dialog,
                                       java.lang.String title)
Brings up a "Ok/Cancel" dialog with no icon. This method can be invoked from any thread and blocks until the user click on "Ok" or "Cancel".

Parameters:
owner - The parent component. Dialog will apears on top of this owner.
dialog - The dialog content to show.
title - The title string for the dialog.
Returns:
if user clicked "Ok", otherwise.

showOptionDialog

public static boolean showOptionDialog(java.awt.Component owner,
                                       java.lang.Object dialog,
                                       java.lang.String title,
                                       java.awt.event.ActionListener reset)
Brings up a "Ok/Cancel/Reset" dialog with no icon. This method can be invoked from any thread and blocks until the user click on "Ok" or "Cancel".

Parameters:
owner - The parent component. Dialog will apears on top of this owner.
dialog - The dialog content to show.
title - The title string for the dialog.
reset - Action to execute when user press "Reset", or if there is no "Reset" button. If is an instance of Action, the button label will be set according the action's properties.
Returns:
if user clicked "Ok", otherwise.

showMessageDialog

public static void showMessageDialog(java.awt.Component owner,
                                     java.lang.Object message,
                                     java.lang.String title,
                                     int type)
Brings up a message dialog with a "Ok" button. This method can be invoked from any thread and blocks until the user click on "Ok".

Parameters:
owner - The parent component. Dialog will apears on top of this owner.
message - The dialog content to show.
title - The title string for the dialog.
type - The message type (JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE).

showConfirmDialog

public static boolean showConfirmDialog(java.awt.Component owner,
                                        java.lang.Object message,
                                        java.lang.String title,
                                        int type)
Brings up a confirmation dialog with "Yes/No" buttons. This method can be invoked from any thread and blocks until the user click on "Yes" or "No".

Parameters:
owner - The parent component. Dialog will apears on top of this owner.
message - The dialog content to show.
title - The title string for the dialog.
type - The message type (JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE).
Returns:
if user clicked on "Yes", otherwise.

getMultilineLabelFor

public static javax.swing.JComponent getMultilineLabelFor(javax.swing.JComponent owner,
                                                          java.lang.String text)
Retourne une ?tiquette pour la composante sp?cifi?e. Le texte de l'?tiquette pourra ?ventuellement ?tre distribu? sur plusieurs lignes.

Parameters:
owner - Composante pour laquelle on construit une ?tiquette. L'?tiquette aura la m?me largeur que .
text - Texte ? placer dans l'?tiquette.

getLocale

public static java.util.Locale getLocale(java.awt.Component component)
Returns the locale for the specified component, or a default one if the component is not yet part of a container hierarchy.


invokeAndWait

public static void invokeAndWait(java.lang.Runnable runnable)
Causes runnable to have its run method called in the dispatch thread of the event queue. This will happen after all pending events are processed. The call blocks until this has happened.



Copyright © GeoTools. All Rights Reserved.