Package org.geotools.util
Class SwingUtilities
Object
SwingUtilities
A collection of utility methods for Swing. All 
show* methods delegate their work to the corresponding
 method in JOptionPane, with two differences:
 - SwingUtilities's method may be invoked from any thread. If they are invoked from a non-Swing thread, execution will be delegate to the Swing thread and the calling thread will block until completion.
- If a parent component is a JDesktopPane, dialogs will be rendered as internal frames instead of frames.
- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
- 
Method SummaryModifier and TypeMethodDescriptionstatic LocaleReturns the locale for the specified component, or a default one if the component is not yet part of a container hierarchy.static JComponentgetMultilineLabelFor(JComponent owner, String text) Retourne une étiquette pour la composante spécifiée.static voidinvokeAndWait(Runnable runnable) Causes runnable to have its run method called in the dispatch thread of the event queue.static voidSet the title of the parent frame or internal frame of the specified component.static booleanshowConfirmDialog(Component owner, Object message, String title, int type) Brings up a confirmation dialog with "Yes/No" buttons.static voidshowMessageDialog(Component owner, Object message, String title, int type) Brings up a message dialog with a "Ok" button.static booleanshowOptionDialog(Component owner, Object dialog, String title) Brings up a "Ok/Cancel" dialog with no icon.static booleanshowOptionDialog(Component owner, Object dialog, String title, ActionListener reset) Brings up a "Ok/Cancel/Reset" dialog with no icon.static ComponenttoFrame(Component owner, JComponent panel, String title, WindowListener listener) Insert a Swing component into a frame.
- 
Method Details- 
toFramepublic static Component toFrame(Component owner, JComponent panel, String title, WindowListener listener) Insert a Swing component into a frame. The kind of frame depends on the owner:- If owneror one of its parent is aJDesktopPane, thenpanelis added into aJInternalFrame.
- If owneror one of its parent is aFrameor aDialog, thenpanelis added into aJDialog.
- Otherwise, panelis added into aJFrame.
 - Parameters:
- owner- The frame's owner, or- nullif 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- listeneris not an instance of- InternalFrameListener, then this method will wrap the- listenerinto an- InternalFrameListener.
- Returns:
- The frame. This frame is not initially visible. The method Component.setVisible(true)must be invoked in order to show the frame.
 
- If 
- 
setTitleSet the title of the parent frame or internal frame of the specified component.
- 
showOptionDialogBrings 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:
- trueif user clicked "Ok",- falseotherwise.
 
- 
showOptionDialogpublic static boolean showOptionDialog(Component owner, Object dialog, String title, 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- nullif there is no "Reset" button. If- resetis an instance of- Action, the button label will be set according the action's properties.
- Returns:
- trueif user clicked "Ok",- falseotherwise.
 
- 
showMessageDialogBrings 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_MESSAGEor- JOptionPane.PLAIN_MESSAGE).
 
- 
showConfirmDialogBrings 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_MESSAGEor- JOptionPane.PLAIN_MESSAGE).
- Returns:
- trueif user clicked on "Yes",- falseotherwise.
 
- 
getMultilineLabelForRetourne 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- owner.
- text- Texte à placer dans l'étiquette.
 
- 
getLocaleReturns the locale for the specified component, or a default one if the component is not yet part of a container hierarchy.
- 
invokeAndWaitCauses 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.
 
-