Package org.moeaframework.util.mvc
Class UI
java.lang.Object
org.moeaframework.util.mvc.UI
Utilities for creating UIs in a consistent manner. For best results, the constructor of the window should be called
within
show(Supplier)
or showAndWait(Supplier)
. Within the constructor:
- Set the window title.
- Layout all components.
- Set
Component.setPreferredSize(java.awt.Dimension)
OS-Specific Details
- Mac (Darwin) - Call
java
with-Xdock:name=...
to set the application title. Otherwise, the class name will appear in the title bar.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Blocks until all events scheduled in the event queue are processed.static void
Configures the system look and feel.static void
Disposes all dialogs and windows.static void
setUseScreenMenuBar
(boolean value) Optionally configure all windows to display their menu in Mac's system menu instead of within the window itself.static <T extends Window>
CompletableFuture<T>Creates a window asynchronously, scheduling the window to be created and displayed on the event dispatch thread.static <T extends Window>
TshowAndWait
(Supplier<T> supplier) Creates a window synchronously.
-
Method Details
-
setUseScreenMenuBar
public static void setUseScreenMenuBar(boolean value) Optionally configure all windows to display their menu in Mac's system menu instead of within the window itself. This has no effect and is safe to call on other operating systems.Must be called before displaying any UI components!
- Parameters:
value
- iftrue
, place menus in the system menu
-
configureLookAndFeel
public static void configureLookAndFeel()Configures the system look and feel.Must be called before displaying any UI components! Note that it is not necessary to call this method explicitly so long as you are displaying windows using the methods in this class, since this method is called automatically when this class is first loaded.
-
show
Creates a window asynchronously, scheduling the window to be created and displayed on the event dispatch thread. The returned future can be used to await this task, blocking until the window is displayed. If invoked from the event dispatch thread, the window is created immediately. Any exceptions will be thrown by the future wrapped in anExecutionException
.- Type Parameters:
T
- the type of window- Parameters:
supplier
- a function that creates the window- Returns:
- the future used to access the displayed window
-
showAndWait
Creates a window synchronously.- Type Parameters:
T
- the type of window- Parameters:
supplier
- a function that creates the window- Returns:
- the window after it is displayed
-
clearEventQueue
public static void clearEventQueue()Blocks until all events scheduled in the event queue are processed. This method no-ops if run from the event dispatch thread. -
disposeAll
public static void disposeAll()Disposes all dialogs and windows.
-