public final class SwingUtilities extends Object
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.
JDesktopPane
, dialogs will be rendered as internal
frames instead of frames.
Modifier and Type | Method and Description |
---|---|
static Locale |
getLocale(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 JComponent |
getMultilineLabelFor(JComponent owner,
String text)
Retourne une étiquette pour la composante spécifiée.
|
static void |
invokeAndWait(Runnable runnable)
Causes runnable to have its run method called in the dispatch thread of the event queue.
|
static void |
setTitle(Component component,
String title)
Set the title of the parent frame or internal frame of the specified component.
|
static boolean |
showConfirmDialog(Component owner,
Object message,
String title,
int type)
Brings up a confirmation dialog with "Yes/No" buttons.
|
static void |
showMessageDialog(Component owner,
Object message,
String title,
int type)
Brings up a message dialog with a "Ok" button.
|
static boolean |
showOptionDialog(Component owner,
Object dialog,
String title)
Brings up a "Ok/Cancel" dialog with no icon.
|
static boolean |
showOptionDialog(Component owner,
Object dialog,
String title,
ActionListener reset)
Brings up a "Ok/Cancel/Reset" dialog with no icon.
|
static Component |
toFrame(Component owner,
JComponent panel,
String title,
WindowListener listener)
Insert a Swing component into a frame.
|
public static Component toFrame(Component owner, JComponent panel, String title, WindowListener listener)
owner
or one of its parent is a JDesktopPane
, then panel
is
added into a JInternalFrame
.
owner
or one of its parent is a Frame
or a Dialog
, then
panel
is added into a JDialog
.
panel
is added into a JFrame
.
owner
- The frame's owner, or null
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 listener
is not an instance of InternalFrameListener
, then
this method will wrap the listener
into an InternalFrameListener
.Component.setVisible(true)
must be invoked in order to show the frame.public static void setTitle(Component component, String title)
public static boolean showOptionDialog(Component owner, Object dialog, String title)
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.true
if user clicked "Ok", false
otherwise.public static boolean showOptionDialog(Component owner, Object dialog, String title, ActionListener reset)
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 null
if there is no
"Reset" button. If reset
is an instance of Action
, the button label will
be set according the action's properties.true
if user clicked "Ok", false
otherwise.public static void showMessageDialog(Component owner, Object message, String title, int type)
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
).public static boolean showConfirmDialog(Component owner, Object message, String title, int type)
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
).true
if user clicked on "Yes", false
otherwise.public static JComponent getMultilineLabelFor(JComponent owner, String text)
owner
- Composante pour laquelle on construit une étiquette. L'étiquette aura la même
largeur que owner
.text
- Texte à placer dans l'étiquette.public static Locale getLocale(Component component)
public static void invokeAndWait(Runnable runnable)
Copyright © 1996–2019 Geotools. All rights reserved.