public class DialogUtils extends Object
Constructor and Description |
---|
DialogUtils() |
Modifier and Type | Method and Description |
---|---|
static <T extends JComponent> |
getChildComponents(Class<T> clazz,
Container parent,
boolean includeNested)
Gets all child components that are, or derive from, the given class.
|
static Dimension |
getHtmlLabelTextExtent(String labelText,
int fixedDimSize,
boolean width)
Calculates the dimensions that a given text string requires when rendered as HTML text in a
label component.
|
static String |
getString(String input,
String fallback)
Returns
input if not null or empty, otherwise returns fallback . |
static void |
showCentred(Window dialog)
Shows a dialog centred on the screen.
|
static void |
showCentredOnParent(Window parent,
Window dialog)
Shows a dialog centred on its parent.
|
public static void showCentred(Window dialog)
dialog
- the dialogpublic static void showCentredOnParent(Window parent, Window dialog)
parent
is null
the dialog is centred on the screen.parent
- the parent componentdialog
- the dialogpublic static <T extends JComponent> List<T> getChildComponents(Class<T> clazz, Container parent, boolean includeNested)
T
- Swing type derived from JComponentclazz
- the component classparent
- the parent containerincludeNested
- whether to recursively collect nested componentspublic static String getString(String input, String fallback)
input
if not null
or empty, otherwise returns fallback
. This
is handy for setting dialog titles etc. Note that the input string is considered empty if
input.trim().length() == 0
.input
- input stringfallback
- fallback string (may be null
)input
unless it is null
or empty, in which case fallback
is
returnedpublic static Dimension getHtmlLabelTextExtent(String labelText, int fixedDimSize, boolean width)
The method used is adapted from that described in a blog post by Morten Nobel:
http://blog.nobel-joergensen.com/2009/01/18/changing-preferred-size-of-a-html-jlabel/
labelText
- the text to render, optionally enclosed in <html>...</html>
tagsfixedDimSize
- the size of the fixed dimension (either width or heightwidth
- true
if the fixed dimension is width; false
for heightCopyright © 1996–2019 Geotools. All rights reserved.