public final class UIUtils extends Object implements ClientProperties
The UIUtils
class provides utility methods for dialog, window
and general UI (user interface) handling.
Modifier and Type | Class and Description |
---|---|
static class |
UIUtils.MessageDialogType
Message types.
|
Modifier and Type | Field and Description |
---|---|
static int |
CANCEL_OPTION
Return value from class method if CANCEL is chosen.
|
static int |
CLOSED_OPTION
Return value from class method if user closes window without selecting
anything, more than likely this should be treated as either a
CANCEL_OPTION or NO_OPTION . |
static int |
DEFAULT_OPTION
Type meaning Look and Feel should not supply any options -- only use the
options from the
JOptionPane . |
static int |
ERROR_MESSAGE
Used for error messages.
|
static int |
INFORMATION_MESSAGE
Used for information messages.
|
static int |
NO_OPTION
Return value from class method if NO is chosen.
|
static int |
OK_CANCEL_OPTION
Type used for
showConfirmDialog . |
static int |
OK_OPTION
Return value form class method if OK is chosen.
|
static int |
PLAIN_MESSAGE
No icon is used.
|
static int |
QUESTION_MESSAGE
Used for questions.
|
static int |
WARNING_MESSAGE
Used for warning messages.
|
static int |
YES_NO_CANCEL_OPTION
Type used for
showConfirmDialog . |
static int |
YES_NO_OPTION
Type used for
showConfirmDialog . |
static int |
YES_OPTION
Return value from class method if YES is chosen.
|
DATA_FIELD, FORMULAR_CONDITION_FILTER, FORMULAR_CONDITION_PRECISION, FORMULAR_FILTER_OPERATOR, FORMULAR_SKIP, FORMULAR_VERIFIER, TAG_DATA
Modifier and Type | Method and Description |
---|---|
static void |
addChildren(Container parent,
XdevList<Component> children,
boolean deep)
|
static ButtonGroup |
createButtonGroup(AbstractButton... buttons)
|
static XdevDialog |
createDialog(XdevWindow content,
Component owner,
boolean modal)
Creates and shows a
XdevDialog hosting the provided
XdevWindow content , using content's title as title
for the dialog. |
static XdevDialog |
createDialog(XdevWindow content,
Component owner,
String title,
boolean modal)
|
static JFileChooser |
createFileChooser(Collection<?> allowedSuffixes)
Shows the system file chooser dialog to select a file.
|
static JFileChooser |
createFolderChooser()
Returns a
JFileChooser configured to chose folders. |
static XdevFrame |
createFrame(XdevWindow content)
Creates and shows a
XdevFrame hosting the provided
XdevWindow content , using content's title as title
for the frame. |
static XdevFrame |
createFrame(XdevWindow content,
String title)
|
static XdevImage |
createImageFrom(Component cpn)
|
static XdevScreen |
createScreen(XdevWindow content,
Component owner)
|
static Window |
getActiveWindow()
Returns the current active
Window . |
static JApplet |
getApplet()
Returns the JApplet of the running application, if the running
application runs as applet.
|
static XdevList<Component> |
getChildrenOf(Container parent,
boolean deep)
|
static Component |
getComponentByName(String name)
Returns the component for the provided
name .Searches for the
component in the current active Window . |
static Component |
getComponentByName(String name,
Window window)
Returns the component for the provided
name . |
static GraphicsConfiguration |
getGraphicsConfigurationOf(Component cpn)
|
static String |
getIP() |
static int |
getMessageType(Severity severity)
Returns the appropriate message type for the specified severity.
|
static <T> T |
getParentOfClass(Class<T> c,
Component cpn)
Convenience method for searching above
cpn in the component
hierarchy and returns the first object of class c it finds. |
static JFileChooser |
getSharedFileChooser()
Returns the shared
JFileChooser . |
static String |
getTagData(Object obj)
Deprecated.
|
static XdevWindow |
getXdevWindowOf(Component component)
|
static XdevWindow |
getXdevWindowOf(Window window)
|
static void |
insertMouseListener(Component cpn,
MouseListener mouseListener,
int index)
|
static void |
insertMouseMotionListener(Component cpn,
MouseMotionListener mouseMotionListener,
int index)
Registers the provided
MouseMotionListener
mouseMotionListener at the desired index for
the Component cpn . |
static boolean |
isDoubleClick(MouseEvent e)
Returns
true if e is a left double click;
otherwise false . |
static boolean |
isLeftMouseButton(MouseEvent e)
Returns
true if the mouse event specifies the left mouse
button. |
static boolean |
isMiddleMouseButton(MouseEvent e)
Returns
true if the mouse event specifies the middle mouse
button. |
static boolean |
isRightMouseButton(MouseEvent e)
Returns
true if the mouse event specifies the right mouse
button. |
static Icon |
loadIcon(String path)
Calls
GraphicUtils.loadIcon(String) and catches the
IOException . |
static <T,C extends Component> |
lookupComponentTree(Container parent,
ComponentTreeVisitor<T,C> visitor)
Shortcut for
lookupComponentTree(parent,visitor,null) . |
static <T,C extends Component> |
lookupComponentTree(Container parent,
ComponentTreeVisitor<T,C> visitor,
Class<C> type)
Walks through the
parent 's component tree hierarchy. |
static void |
move(Component cpn,
int x,
int y,
boolean relative)
Moves the
Component cpn to the specified position. |
static void |
move(Component cpn,
int toX,
int toY,
long duration,
boolean relative,
boolean wait)
Moves the
Component cpn to the specified position. |
static void |
pause(long millis)
Causes the currently executing thread to sleep (temporarily cease
execution) for the specified number of milliseconds, subject to the
precision and accuracy of system timers and schedulers.
|
static void |
registerPopup(Component cpn,
XdevMenu popup)
Registers listeners to the component to show the popup in the platform's
specific manner.
To register a popup to a JTree TreeUtils.registerPopup(JTree, XdevMenu) is the preferred way. |
static void |
registerPopupHandler(Component cpn,
PopupHandler handler)
Registers listeners to the component to show the popup in the platform's
specific manner.
To register a popup to a JTree TreeUtils.registerPopupHandler(JTree, xdev.ui.tree.TreePopupHandler)
is the preferred way. |
static void |
registerShortcut(AbstractButton button,
KeyStroke keyStroke)
Registers a keyboard shortcut for the specified
button . |
static void |
removeMouseListener(Component cpn,
Class<? extends MouseListener> type)
|
static void |
removeMouseMotionListener(Component cpn,
Class<? extends MouseMotionListener> type)
|
static void |
runInSwingThread(Runnable runnable)
Ensures that the runnable is executed in the Java Swing thread.
|
static void |
scale(Component cpn,
int x,
int y,
int width,
int height,
boolean relative)
|
static void |
scale(Component cpn,
int toX,
int toY,
int toWidth,
int toHeight,
long duration,
boolean wait)
|
static void |
scrollToStart(JComponent cpn)
Scrolls to the visible start of the component, e.g.
|
static void |
setBorderTitle(JComponent cpn,
String title)
Sets the border title for provided
JComponent cpn . |
static EnabledState |
setEnabled(Container root,
boolean enabled)
|
static void |
setQualityHints(Graphics2D g)
Set rendering hints to quality on the provided
Graphics2D g . |
static void |
setSpeedHints(Graphics2D g)
Set rendering hints to speed on the provided
Graphics2D g . |
static void |
setTagData(Object obj,
String tagData)
Deprecated.
|
static Color |
showColorChooser(String title,
Color initialColor)
Shows a
JColorChooser dialog so the user can choose a
Color . |
static Object |
showConfirmMessage(String title,
String message,
Collection<?> options,
int selectedIndex,
int messageType)
Brings up a simple confirm dialog with the specified icon.
|
static Object |
showConfirmMessage(String title,
String message,
Collection<?> options,
int selectedIndex,
UIUtils.MessageDialogType messageDialogType)
Brings up a simple confirm dialog with the specified icon.
|
static Object |
showConfirmMessage(String title,
String message,
Object[] options,
int selectedIndex,
int messageType)
Brings up a simple confirm dialog with the specified icon.
|
static Object |
showConfirmMessage(String title,
String message,
Object[] options,
int selectedIndex,
UIUtils.MessageDialogType messageDialogType)
Brings up a simple confirm dialog with the specified icon.
|
static boolean |
showConfirmMessage(String title,
String message,
String ok,
String cancel)
Brings up a simple confirm dialog.
|
static boolean |
showConfirmMessage(String title,
String message,
String ok,
String cancel,
int messageType)
Brings up a simple confirm dialog with the specified icon.
|
static boolean |
showConfirmMessage(String title,
String message,
String ok,
String cancel,
UIUtils.MessageDialogType messageDialogType)
Brings up a simple confirm dialog with the specified icon.
|
static XdevFile |
showFileChooser()
Shows the system file chooser dialog to select a file.
|
static XdevFile |
showFileChooser(Collection<?> allowedSuffixes)
Shows the system file chooser dialog to select a file.
|
static XdevFile |
showFileChooser(String okButtonText,
Collection<?> allowedSuffixes)
Shows the system file chooser dialog to select a file.
|
static XdevFile |
showFileChooser(String okButtonText,
Collection<?> allowedSuffixes,
String initialPath)
Shows the system file chooser dialog to select a file.
|
static XdevFile |
showFolderChooser()
Shows the system file chooser dialog to select a folder.
|
static XdevFile |
showFolderChooser(String okButtonText)
Shows the system file chooser dialog to select a folder.
|
static XdevFile |
showFolderChooser(String okButtonText,
String initialPath)
Shows the system file chooser dialog to select a folder.
|
static void |
showMessage(String title,
String message)
Brings up a dialog that displays a message using a no icon.
|
static void |
showMessage(String title,
String message,
int messageType)
Brings up a dialog that displays a message using a default icon
determined by the
messageType parameter. |
static void |
showMessage(String title,
String message,
UIUtils.MessageDialogType messageDialogType)
Brings up a dialog that displays a message using a default icon
determined by the
messageType parameter. |
static void |
toBack(Component cpn)
Sets the provided
Component cpn to back. |
static void |
toFront(Component cpn)
Sets the provided
Component cpn to front. |
static String |
toString(JComponent cpn)
|
static boolean |
validateState(FormularComponent formCpn)
Validates the state of
formCpn using the Validator s
of the FormularComponent and displays an error if one of the
validators throws an error. |
static boolean |
verifyFormularComponent(JComponent cpn)
Deprecated.
use
validateState(FormularComponent) instead |
public static final int DEFAULT_OPTION
JOptionPane
.public static final int YES_NO_OPTION
showConfirmDialog
.public static final int YES_NO_CANCEL_OPTION
showConfirmDialog
.public static final int OK_CANCEL_OPTION
showConfirmDialog
.public static final int YES_OPTION
public static final int NO_OPTION
public static final int CANCEL_OPTION
public static final int OK_OPTION
public static final int CLOSED_OPTION
CANCEL_OPTION
or NO_OPTION
.public static final int ERROR_MESSAGE
public static final int INFORMATION_MESSAGE
public static final int WARNING_MESSAGE
public static final int QUESTION_MESSAGE
public static final int PLAIN_MESSAGE
public static void setSpeedHints(Graphics2D g) throws NullPointerException
Graphics2D
g
.g
- Graphics2D
to set the rendering hints on.NullPointerException
- if provided Graphics2D
g
is
null
.public static void setQualityHints(Graphics2D g) throws NullPointerException
Graphics2D
g
.g
- Graphics2D
to set the rendering hints on.NullPointerException
- if provided Graphics2D
g
is
null
.public static Icon loadIcon(String path)
GraphicUtils.loadIcon(String)
and catches the
IOException
.path
- the relative path of the icon, e.g. 'res/image/splash.png'null
if an IOException
occurspublic static XdevWindow getXdevWindowOf(Component component)
XdevWindow
on which the provided Component
component
is located on. If the provided Component
component
is not placed on a XdevWindow
null
will be returned.component
- Component
to get the XdevWindow
for.XdevWindow
on which the provided Component
component
is located on. If the provided
Component
component
is not placed on a
XdevWindow
null
will be returned.public static <T> T getParentOfClass(Class<T> c, Component cpn)
cpn
in the component
hierarchy and returns the first object of class c
it finds.
Can return null
, if a class c
cannot be found.c
- The type to search forcpn
- The starting point in the component hierarchycpn
or null
if no owner of
type c
could be foundpublic static JFileChooser getSharedFileChooser()
JFileChooser
.
Hint: Does not show the JFileChooser
. To show
the JFileChooser
use showFileChooser(String, Collection)
.
JFileChooser
.public static JFileChooser createFolderChooser()
JFileChooser
configured to chose folders.
Hint: Does not show the JFileChooser
. To show
the JFileChooser
use showFolderChooser(String)
.
JFileChooser
configured to chose folders.public static XdevFile showFolderChooser()
The chooser starts the last use folder.
null
if the user closes the
dialog or does not select a folder.public static XdevFile showFolderChooser(String okButtonText)
The chooser starts the last use folder.
okButtonText
- String
to use as text for the ok button of the
folder chooser. If null
the default text is used.null
if the user closes the
dialog or does not select a folder.public static XdevFile showFolderChooser(String okButtonText, String initialPath)
okButtonText
- String
to use as text for the ok button of the
folder chooser. If null
the default text is used.initialPath
- String
path to open the file chooser for. If
null
the folder chooser starts in the last
used folder.null
if the user closes the
dialog or does not select a folder.public static XdevFile showFileChooser()
The chooser starts in the last used folder.
Hint:
For a more sophisticated way to use file choosers see
XdevFileChooserFactory
.
null
if the user closes the
dialog or does not select a folder.public static XdevFile showFileChooser(Collection<?> allowedSuffixes)
The chooser starts in the last used folder.
Hint:
For a more sophisticated way to use file choosers see
XdevFileChooserFactory
.
allowedSuffixes
- a Collection
containing the allowed suffixes for files
this file chooser should display. If null
or
empty (= list with not entries) all files will be displayed.null
if the user closes the
dialog or does not select a folder.public static XdevFile showFileChooser(String okButtonText, Collection<?> allowedSuffixes)
The chooser starts in the last used folder.
Hint:
For a more sophisticated way to use file choosers see
XdevFileChooserFactory
.
okButtonText
- String
to use as text for the ok button of the
file chooser. If null
the default text is used.allowedSuffixes
- a Collection
containing the allowed suffixes for files
this file chooser should display. If null
or
empty (= list with not entries) all files will be displayed.null
if the user closes the
dialog or does not select a folder.public static XdevFile showFileChooser(String okButtonText, Collection<?> allowedSuffixes, String initialPath)
Hint:
For a more sophisticated way to use file choosers see
XdevFileChooserFactory
.
okButtonText
- String
to use as text for the ok button of the
file chooser. If null
the default text is used.allowedSuffixes
- a Collection
containing the allowed suffixes for files
this file chooser should display. If null
or
empty (= list with not entries) all files will be displayed.initialPath
- String
path to open the file chooser for. If
null
the folder chooser starts in the last
used folder.null
if the user closes the
dialog or does not select a folder.public static JFileChooser createFileChooser(Collection<?> allowedSuffixes)
The standard ok button text is used. The chooser starts in the last used folder.
Hint: Does not show the JFileChooser
. To show
the JFileChooser
use showFileChooser(String, Collection)
.
Hint:
For a more sophisticated way to use file choosers see
XdevFileChooserFactory
.
allowedSuffixes
- a Collection
containing the allowed suffixes for files
this file chooser should display. If null
or
empty (= list with not entries) all files will be displayed.null
if the user closes the
dialog or does not select a folder.public static Color showColorChooser(String title, Color initialColor)
JColorChooser
dialog so the user can choose a
Color
.title
- String
title of the dialog. If null
the
chooser title will be empty.initialColor
- Color
to start with. If null
the chooser
is started with Color.white
.Color
; or null
if the user
closes the dialog or does not select a Color
.public static <T,C extends Component> T lookupComponentTree(Container parent, ComponentTreeVisitor<T,C> visitor)
lookupComponentTree(parent,visitor,null)
.T
- The return typeC
- The component type to visitparent
- The root of the component tree to visitvisitor
- the ComponentTreeVisitor
ComponentTreeVisitor
public static <T,C extends Component> T lookupComponentTree(Container parent, ComponentTreeVisitor<T,C> visitor, Class<C> type)
parent
's component tree hierarchy.
For every child in the tree hierarchy, which fits the type
parameter (or type is null
), the visitor
's
ComponentTreeVisitor.visit(Component)
is invoked.
If the visit
method returns a value != null
,
the visitation ends and that value is returned.
T
- The return typeC
- The component type to visitparent
- The root of the component tree to visitvisitor
- the ComponentTreeVisitor
type
- The component type class to visitComponentTreeVisitor
public static Window getActiveWindow()
Window
.Window
.public static void showMessage(String title, String message)
message
- the message to displaytitle
- the title string for the dialogshowMessage(String, String, int)
public static void showMessage(String title, String message, int messageType)
messageType
parameter.message
- the message to displaytitle
- the title string for the dialogmessageType
- the type of message to be displayed:
ERROR_MESSAGE
, INFORMATION_MESSAGE
,
WARNING_MESSAGE
, QUESTION_MESSAGE
,
or PLAIN_MESSAGE
ERROR_MESSAGE
,
WARNING_MESSAGE
,
INFORMATION_MESSAGE
,
QUESTION_MESSAGE
,
PLAIN_MESSAGE
public static void showMessage(String title, String message, UIUtils.MessageDialogType messageDialogType)
messageType
parameter.message
- the message to displaytitle
- the title string for the dialogmessageDialogType
- the type of message to be displayed:
UIUtils.MessageDialogType.ERROR_MESSAGE
,
UIUtils.MessageDialogType.INFORMATION_MESSAGE
UIUtils.MessageDialogType.WARNING_MESSAGE
,
UIUtils.MessageDialogType.QUESTION_MESSAGE
, or
UIUtils.MessageDialogType.PLAIN_MESSAGE
UIUtils.MessageDialogType
public static boolean showConfirmMessage(String title, String message, String ok, String cancel)
public static boolean showConfirmMessage(String title, String message, String ok, String cancel, int messageType)
message
- the message to displaytitle
- the title string for the dialogok
- String
to use as text for the ok button.cancel
- String
to use as text for the cancel button.messageType
- the type of message to be displayed:
ERROR_MESSAGE
, INFORMATION_MESSAGE
,
WARNING_MESSAGE
, QUESTION_MESSAGE
,
or PLAIN_MESSAGE
true
if the user selected the ok button;
otherwise false
.ERROR_MESSAGE
,
WARNING_MESSAGE
,
INFORMATION_MESSAGE
,
QUESTION_MESSAGE
,
PLAIN_MESSAGE
public static boolean showConfirmMessage(String title, String message, String ok, String cancel, UIUtils.MessageDialogType messageDialogType) throws NullPointerException
message
- the message to displaytitle
- the title string for the dialogok
- String
to use as text for the ok button.cancel
- String
to use as text for the cancel button.messageDialogType
- the type of message to be displayed:
UIUtils.MessageDialogType.ERROR_MESSAGE
,
UIUtils.MessageDialogType.INFORMATION_MESSAGE
UIUtils.MessageDialogType.WARNING_MESSAGE
,
UIUtils.MessageDialogType.QUESTION_MESSAGE
, or
UIUtils.MessageDialogType.PLAIN_MESSAGE
true
if the user selected the ok button;
otherwise false
.NullPointerException
- if messageDialogType
is null
UIUtils.MessageDialogType
public static Object showConfirmMessage(String title, String message, Collection<?> options, int selectedIndex, int messageType)
message
- the message to displaytitle
- the title string for the dialogoptions
- an Collection
of objects indicating the possible
choices the user can make; if the objects are components, they
are rendered properly; non-String
objects are
rendered using their toString
methods; if this
parameter is null
, the options are determined by
the Look and FeelselectedIndex
- the index of the option that should be the default selection
for the dialog. The first element of options has the
index 0
.messageType
- the type of message to be displayed:
ERROR_MESSAGE
, INFORMATION_MESSAGE
,
WARNING_MESSAGE
, QUESTION_MESSAGE
,
or PLAIN_MESSAGE
option
object indicating the option chosen by
the user, or null
if the user closed the dialog.ERROR_MESSAGE
,
WARNING_MESSAGE
,
INFORMATION_MESSAGE
,
QUESTION_MESSAGE
,
PLAIN_MESSAGE
public static Object showConfirmMessage(String title, String message, Collection<?> options, int selectedIndex, UIUtils.MessageDialogType messageDialogType) throws NullPointerException
message
- the message to displaytitle
- the title string for the dialogoptions
- an Collection
of objects indicating the possible
choices the user can make; if the objects are components, they
are rendered properly; non-String
objects are
rendered using their toString
methods; if this
parameter is null
, the options are determined by
the Look and FeelselectedIndex
- the index of the option that should be the default selection
for the dialog. The first element of options has the
index 0
.messageDialogType
- the type of message to be displayed:
UIUtils.MessageDialogType.ERROR_MESSAGE
,
UIUtils.MessageDialogType.INFORMATION_MESSAGE
UIUtils.MessageDialogType.WARNING_MESSAGE
,
UIUtils.MessageDialogType.QUESTION_MESSAGE
, or
UIUtils.MessageDialogType.PLAIN_MESSAGE
option
object indicating the option chosen by
the user, or null
if the user closed the dialog.NullPointerException
- if messageDialogType
is null
UIUtils.MessageDialogType
public static Object showConfirmMessage(String title, String message, Object[] options, int selectedIndex, int messageType)
message
- the message to displaytitle
- the title string for the dialogoptions
- an array of objects indicating the possible choices the user
can make; if the objects are components, they are rendered
properly; non-String
objects are rendered using
their toString
methods; if this parameter is
null
, the options are determined by the Look and
FeelselectedIndex
- the index of the option that should be the default selection
for the dialog. The first element of options has the
index 0
.messageType
- the type of message to be displayed:
ERROR_MESSAGE
, INFORMATION_MESSAGE
,
WARNING_MESSAGE
, QUESTION_MESSAGE
,
or PLAIN_MESSAGE
option
object indicating the option chosen by
the user, or null
if the user closed the dialog.ERROR_MESSAGE
,
WARNING_MESSAGE
,
INFORMATION_MESSAGE
,
QUESTION_MESSAGE
,
PLAIN_MESSAGE
public static Object showConfirmMessage(String title, String message, Object[] options, int selectedIndex, UIUtils.MessageDialogType messageDialogType) throws NullPointerException
message
- the message to displaytitle
- the title string for the dialogoptions
- an array of objects indicating the possible choices the user
can make; if the objects are components, they are rendered
properly; non-String
objects are rendered using
their toString
methods; if this parameter is
null
, the options are determined by the Look and
FeelselectedIndex
- the index of the option that should be the default selection
for the dialog. The first element of options has the
index 0
.messageDialogType
- the type of message to be displayed:
UIUtils.MessageDialogType.ERROR_MESSAGE
,
UIUtils.MessageDialogType.INFORMATION_MESSAGE
UIUtils.MessageDialogType.WARNING_MESSAGE
,
UIUtils.MessageDialogType.QUESTION_MESSAGE
, or
UIUtils.MessageDialogType.PLAIN_MESSAGE
option
object indicating the option chosen by
the user, or null
if the user closed the dialog.NullPointerException
- if messageDialogType
is null
UIUtils.MessageDialogType
public static String getIP()
public static void pause(long millis)
millis
- the length of time to sleep in milliseconds.public static Component getComponentByName(String name)
name
.Searches for the
component in the current active Window
.name
- to get component for.window
; otherwise null
.public static Component getComponentByName(String name, Window window)
name
- to get component for.window
- Window
to search for the component in.window
; otherwise null
.public static JApplet getApplet()
null
.public static XdevFrame createFrame(XdevWindow content)
XdevFrame
hosting the provided
XdevWindow
content
, using content's title as title
for the frame.content
- XdevWindow
to display in the frameXdevFrame
with the provided
title
, hosting the provided XdevWindow
content
.public static XdevFrame createFrame(XdevWindow content, String title)
content
- XdevWindow
to display in the frametitle
- title of the frameXdevFrame
with the provided
title
, hosting the provided XdevWindow
content
.public static XdevDialog createDialog(XdevWindow content, Component owner, boolean modal)
XdevDialog
hosting the provided
XdevWindow
content
, using content's title as title
for the dialog.content
- XdevWindow
to display in the dialogowner
- the owner of the dialogmodal
- if true
the dialog is modal; otherwise it is notXdevDialog
with the provided
title
, hosting the provided XdevWindow
content
.public static XdevDialog createDialog(XdevWindow content, Component owner, String title, boolean modal)
content
- XdevWindow
to display in the dialogowner
- the owner of the dialogtitle
- title of the dialogmodal
- if true
the dialog is modal; otherwise it is notXdevDialog
with the provided
title
, hosting the provided XdevWindow
content
.public static XdevScreen createScreen(XdevWindow content, Component owner)
content
- XdevWindow
to display in the windowowner
- the owner of the windowXdevScreen
with the provided
title
, hosting the provided XdevWindow
content
.public static void move(Component cpn, int x, int y, boolean relative)
Component
cpn
to the specified position.public static void move(Component cpn, int toX, int toY, long duration, boolean relative, boolean wait)
Component
cpn
to the specified position.cpn
- Component
to movetoX
- new x coordinate of the Component
toY
- new y coordinate of the Component
duration
- duration of the move operation in millisecondsrelative
- if true the Component will be moved relative to is current
position; other wise the Component will be moved absolute.wait
- if true
the moving operation forces all following
operations to wait for it to finish; otherwise the following
operation will start immediately.public static void scale(Component cpn, int x, int y, int width, int height, boolean relative)
Component
cpn
to the specified position
and scales the Component
to fit the new width
and
height
.cpn
- Component
to movex
- new x coordinate of the Component
y
- new y coordinate of the Component
width
- new width of the Component
height
- new height of the Component
relative
- if true the Component will be moved relative to is current
position; other wise the Component will be moved absolute.public static void scale(Component cpn, int toX, int toY, int toWidth, int toHeight, long duration, boolean wait)
Component
cpn
to the specified position
and scales the Component
to fit the new width
and
height
.cpn
- Component
to movetoX
- new x coordinate of the Component
toY
- new y coordinate of the Component
duration
- duration of the move operation in millisecondstoWidth
- new width of the Component
toHeight
- new height of the Component
wait
- if true
the moving operation forces all following
operations to wait for it to finish; otherwise the following
operation will start immediately.public static void toFront(Component cpn)
Component
cpn
to front.cpn
- Component to set to frontpublic static void toBack(Component cpn)
Component
cpn
to back.cpn
- Component to set to back@Deprecated public static boolean verifyFormularComponent(JComponent cpn)
validateState(FormularComponent)
insteadJComponent
cpn
using
the set constrains of the component.cpn
- JComponent
to check value ontrue
if the value of the component is valid or the
component has no constaints set; otherwise false
public static boolean validateState(FormularComponent formCpn)
formCpn
using the Validator
s
of the FormularComponent
and displays an error if one of the
validators throws an error.formCpn
- the component to validatefalse
if at least one of the validators returns with
an error, true
otherwisepublic static int getMessageType(Severity severity)
Severity.ERROR
-> ERROR_MESSAGE
Severity.WARNING
-> WARNING_MESSAGE
Severity.INFORMATION
-> INFORMATION_MESSAGE
severity
- public static void setBorderTitle(JComponent cpn, String title)
JComponent
cpn
.
Hint: Works only if the component has a
TitledBorder
. You can set a TitledBorder
for a component
via XDEV IDE or manually with JComponent.setBorder(Border)
.
cpn
- JComponent
to set the title fortitle
- String
to be displayed in title of the border.JComponent.setBorder(Border)
public static String toString(JComponent cpn)
cpn
- JComponent
to get the String
representation
for.String
representation of the provided
JComponent
cpn
or null
if no
suitable String
could be created.@Deprecated public static String getTagData(Object obj)
@Deprecated public static void setTagData(Object obj, String tagData)
obj
- Object to set the tagData
for.tagData
- to set for the provided objectpublic static EnabledState setEnabled(Container root, boolean enabled)
Component.setEnabled(boolean)
method on all
Component
s in the provided Container
root
.
For the Container
itself the method is also called.
Before this a EnabledState
is created to store the original
state. This state is returned.
Hint: This is a deep operation that also affects all
children of children of root
and so on.
root
- Container
to perform the operation onenabled
- true
to enable all Component
s;
false
to disable all Component
s.EnabledState
EnabledState
public static void addChildren(Container parent, XdevList<Component> children, boolean deep)
public static void insertMouseListener(Component cpn, MouseListener mouseListener, int index)
cpn
- Component
to register the MouseListener
formouseListener
- MouseListener
to registerindex
- desired position of the MouseListener
public static void removeMouseListener(Component cpn, Class<? extends MouseListener> type)
cpn
- Component
to unregister the MouseListener
fortype
- class of the MouseListener
s to unregisterpublic static void insertMouseMotionListener(Component cpn, MouseMotionListener mouseMotionListener, int index)
MouseMotionListener
mouseMotionListener
at the desired index
for
the Component
cpn
.cpn
- Component
to register the MouseMotionListener
formouseMotionListener
- MouseMotionListener
to registerindex
- desired position of the MouseMotionListener
public static void removeMouseMotionListener(Component cpn, Class<? extends MouseMotionListener> type)
cpn
- Component
to unregister the
MouseMotionListener
fortype
- class of the MouseMotionListener
s to unregisterpublic static ButtonGroup createButtonGroup(AbstractButton... buttons)
buttons
- members of the new ButtonGroup
ButtonGroup
containing the provided
AbstractButton
buttons
.public static void registerShortcut(AbstractButton button, KeyStroke keyStroke)
button
.public static XdevWindow getXdevWindowOf(Window window)
window
- to get the XdevWindow
forXdevWindow
of the specified Window
window
or null
if the Window
does not contain a XdevWindow
.public static GraphicsConfiguration getGraphicsConfigurationOf(Component cpn)
cpn
- Component
to get the GraphicsConfiguration
forGraphicsConfiguration
for the provided
Component
cpn
.public static boolean isDoubleClick(MouseEvent e)
true
if e
is a left double click;
otherwise false
.e
- MouseEvent
to be checkedtrue
if e
is a left double click;
otherwise false
.public static boolean isLeftMouseButton(MouseEvent e)
true
if the mouse event specifies the left mouse
button.e
- a MouseEvent objecttrue
if the left mouse button was activepublic static boolean isMiddleMouseButton(MouseEvent e)
true
if the mouse event specifies the middle mouse
button.e
- a MouseEvent objecttrue
if the middle mouse button was activepublic static boolean isRightMouseButton(MouseEvent e)
true
if the mouse event specifies the right mouse
button.e
- a MouseEvent objecttrue
if the right mouse button was activepublic static void registerPopup(Component cpn, XdevMenu popup)
TreeUtils.registerPopup(JTree, XdevMenu)
is the preferred way.cpn
- popup
- public static void registerPopupHandler(Component cpn, PopupHandler handler)
TreeUtils.registerPopupHandler(JTree, xdev.ui.tree.TreePopupHandler)
is the preferred way.cpn
- handler
- public static void scrollToStart(JComponent cpn)
cpn
- public static void runInSwingThread(Runnable runnable)
Copyright © 2003–2021 XDEV Software. All rights reserved.