public enum SwingUtilitiesN extends Enum<SwingUtilitiesN>
SwingUtilities
Modifier and Type | Method and Description |
---|---|
static <T> T |
callAndWait(@NotNull Callable<T> callable)
Causes
callable.call() to be executed synchronously on the AWT event dispatching thread. |
static <T> FutureTask<T> |
callLater(@NotNull Callable<T> callable)
Causes
callable.call() to be executed asynchronously on the AWT event dispatching thread. |
static <T extends Component> |
findComponent(@NotNull Class<T> componentClass,
Container... containers)
Finds a component in a list of containers.
|
static <T extends Component> |
findComponent(@NotNull Predicate test,
Container... containers)
Finds a component in a list of containers.
|
static Optional<JMenu> |
findJMenu(JMenuBar jMenuBar,
String actionCommand) |
static Optional<JMenu> |
findJMenu(JMenu jMenu,
String actionCommand) |
static String[] |
getColumnNames(@NotNull JTable jTable) |
static ImageIcon |
getImageIcon(String urlString) |
static List<String[]> |
getTableValues(@NotNull JTable jTable) |
static void |
initActionFromBundle(@NotNull Action action,
@NotNull ResourceBundle resourceBundle)
Initializes an action from a ResourceBundle.
|
static void |
initActionFromBundle(@NotNull Action action,
@NotNull String actionCommand,
@NotNull ResourceBundle resourceBundle)
Initializes an action from a ResourceBundle.
|
static void |
setLookAndFeelFromClassName(String className,
Window frame) |
static void |
setLookAndFeelFromName(@Nullable String lookAndFeelName)
Sets the current look and feel to the look and feel specified by
lookAndFeelName . |
static SwingUtilitiesN |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SwingUtilitiesN[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static SwingUtilitiesN[] values()
for (SwingUtilitiesN c : SwingUtilitiesN.values()) System.out.println(c);
public static SwingUtilitiesN valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static <T extends Component> Optional<T> findComponent(@NotNull @NotNull Class<T> componentClass, @NotNull Container... containers)
T
- Type of the component to find.componentClass
- Class of the component to find.containers
- Containers in which to find a component of the specified class.null
.NullPointerException
- in case componentClass
or containers
is null
.IllegalArgumentException
- in case componentClass
or containers
is null
(IntelliJ IDEA).public static <T extends Component> Optional<T> findComponent(@NotNull @NotNull Predicate test, @NotNull Container... containers)
T
- Type of the component to find.test
- Predicate to find the component.containers
- Containers in which to find a component of the specified class.null
.NullPointerException
- in case componentClass
or containers
is null
.IllegalArgumentException
- in case componentClass
or containers
is null
(IntelliJ IDEA).public static <T> T callAndWait(@NotNull @NotNull Callable<T> callable) throws InvocationTargetException, InterruptedException, ExecutionException
callable.call()
to be executed synchronously on the AWT event dispatching thread.
This blocks until all pending AWT events have been processed and (then) callable.call()
returns.
This method should be used when an application thread needs to update the GUI.
It shouldn't be called from the event dispatching thread.
Here's an Example that shows a dialog from an application thread.
new Thread(() -> { try { System.err.println(SwingUtilitiesN.callAndWait(() -> JOptionPane.showInputDialog("Enter your name"))); } catch (final InvocationTargetException | InterruptedException | ExecutionException e) { e.printStackTrace(); } }).start();
T
- The type of the return value of callable
callable
- Callable to execute on the event thread.callable
ExecutionException
- if an exception is thrown while running callable
InterruptedException
- if we're interrupted while waiting for the event dispatching thread to finish executing callable.call()
InvocationTargetException
- if an exception is thrown within FutureTask before or after callable.call()
NullPointerException
- in case callable
is null
.IllegalArgumentException
- in case callable
is null
(IntelliJ IDEA).public static <T> FutureTask<T> callLater(@NotNull @NotNull Callable<T> callable)
callable.call()
to be executed asynchronously on the AWT event dispatching thread.
This will happen after all pending AWT events have been processed.
This method should be used when an application thread needs to update the GUI.T
- The type of the return value of callable
callable
- Callable to execute on the event thread.callable
.NullPointerException
- in case callable
is null
.IllegalArgumentException
- in case callable
is null
(IntelliJ IDEA).public static void setLookAndFeelFromName(@Nullable @Nullable String lookAndFeelName)
lookAndFeelName
.lookAndFeelName
- Name of the look and feel to set, for example "Metal"
or "Nimbus"
.
If this is null
, the look and feel remains unchanged.public static void initActionFromBundle(@NotNull @NotNull Action action, @NotNull @NotNull String actionCommand, @NotNull @NotNull ResourceBundle resourceBundle)
action
- Action to initialize.actionCommand
- actionCommand, at the same time the base for the keys in the resourceBundle
.resourceBundle
- ResourceBundle from which to initialize the action.NullPointerException
- in case action
or actionCommand
or resourceBundle
is null
.IllegalArgumentException
- in case action
or actionCommand
or resourceBundle
is null
(IntelliJ IDEA).public static void initActionFromBundle(@NotNull @NotNull Action action, @NotNull @NotNull ResourceBundle resourceBundle)
Action.ACTION_COMMAND_KEY
set or this method will throw a NullPointerException
.action
- Action to initialize (with set Action.ACTION_COMMAND_KEY
).resourceBundle
- ResourceBundle from which to initialize the action.NullPointerException
- in case action
or actionCommand.getValue(ACTION_COMMAND_KEY)
or resourceBundle
is null
.IllegalArgumentException
- in case action
or actionCommand.getValue(ACTION_COMMAND_KEY)
or resourceBundle
is null
(IntelliJ IDEA).public static void setLookAndFeelFromClassName(String className, Window frame)
Copyright © 2016 Nelkinda Software Craft Pvt Ltd. All rights reserved.