public interface IGuiUtils
To make everyone's GUI life easier.
IUtils
Modifier and Type | Method and Description |
---|---|
boolean |
askRetry(java.lang.Object... messages)
Shows a YES-NO confirmation dialog to the user about retrying a failed operation.
|
void |
autoCreateDisabledImage(javax.swing.JButton button)
If the specified button is created using an instance of
IAction returned by the API, this method registers a PropertyChangeListener to
the button for the AbstractButton.ICON_CHANGED_PROPERTY property, and creates and sets the disabled icon using the HasRIcon.getRicon() as
the icon source and the tool bar icon size setting as the size. |
<T extends java.awt.Component> |
boldFont(T comp)
Changes the font of the specified component to
bold . |
java.awt.Color |
colorWithAlpha(java.awt.Color c,
int alpha)
Creates a new
Color from the specified color using the specified alpha. |
boolean |
confirm(java.lang.Object... messages)
Shows a YES-NO confirmation dialog to the user.
|
<T extends java.awt.Component> |
italicFont(T comp)
Changes the font of the specified component to
italic . |
java.lang.String |
keyStrokeToString(javax.swing.KeyStroke keyStroke)
Returns a nice string representation of the specified key stroke.
|
ILink |
linkForAction(java.lang.String text,
IAction action)
Creates a new
ILink which executes the specified action. |
void |
makeComponentDragScrollable(javax.swing.JComponent component)
Makes a component drag-scrollable.
|
void |
maximizeWindowWithMargin(java.awt.Window window,
int margin,
java.awt.Dimension maxSize)
Resizes a window by setting its bounds to maximum that fits inside the default screen having the specified margin around it, and centers the window on
the screen.
|
javax.swing.JLabel |
renderToLabel(javax.swing.JLabel l,
java.lang.Object value,
boolean isSelected,
boolean hasFocus)
Performs the advanced, unified rendering logic which targets a
JLabel . |
java.lang.Exception |
runInEDT(java.lang.Runnable task)
Runs the specified task in the EDT.
If the current thread is the EDT, simply task.run() will be called. |
void |
setComponentTreeEnabled(java.awt.Component component,
boolean enabled)
Sets the enabled property of a component tree recursively.
|
void |
showErrorMsg(java.lang.Object... messages)
Shows an error message.
|
void |
showInfoMsg(java.lang.Object... messages)
Shows an info message.
|
boolean |
showInputMsg(java.lang.Object... messages)
Shows an input message.
|
void |
showSendEmailDialog(java.util.List<java.nio.file.Path> attachmentList)
Shows the email sender dialog.
|
void |
showSendEmailDialog(java.lang.String to)
Shows the email sender dialog.
|
void |
showSendEmailDialog(java.lang.String title,
java.util.List<java.nio.file.Path> attachmentList,
java.lang.String to)
Shows the email sender dialog.
|
void |
showWarningMsg(java.lang.Object... messages)
Shows a warning message.
|
<T extends java.awt.Component> T italicFont(T comp)
italic
.T
- type of the componentcomp
- the component whose font to changeboldFont(Component)
<T extends java.awt.Component> T boldFont(T comp)
bold
.T
- type of the componentcomp
- the component whose font to changeitalicFont(Component)
void maximizeWindowWithMargin(java.awt.Window window, int margin, java.awt.Dimension maxSize)
The implementation takes the screen insets (for example space occupied by task bar) into account.
window
- window to be resizedmargin
- margin to leave around the windowmaxSize
- optional parameter defining a maximum sizevoid autoCreateDisabledImage(javax.swing.JButton button)
IAction
returned by the API, this method registers a PropertyChangeListener
to
the button for the AbstractButton.ICON_CHANGED_PROPERTY
property, and creates and sets the disabled icon using the HasRIcon.getRicon()
as
the icon source and the tool bar icon size setting as the size.
Problem and its origin: buttons having an icon not an instance of ImageIcon
will have the same disabled icon (and not a grayed version).
This is the case with buttons created using an IAction
whose large icon property will be used for the button's icon which is the icon returned by
IRIcon.size(int)
).
button
- button to have disabled image auto-createdjava.lang.Exception runInEDT(java.lang.Runnable task)
task.run()
will be called. Else SwingUtilities.invokeAndWait(Runnable)
will be used.task
- task to be run in the EDTSwingUtilities.invokeAndWait(Runnable)
; null
otherwiseboolean confirm(java.lang.Object... messages)
This method blocks until the dialog is closed.
messages
- messages and components to be displayed to the userboolean askRetry(java.lang.Object... messages)
This method blocks until the dialog is closed.
Can be called outside of the EDT.
Example usage:
while ( !deleteFile( file ) ) if ( !askRetry( "Could not delete file:", file ) ) break;
messages
- messages and components to be displayed to the user; a "Retry?" label will be addedvoid showInfoMsg(java.lang.Object... messages)
This method blocks until the dialog is closed.
messages
- info messages and components to be displayedvoid showErrorMsg(java.lang.Object... messages)
This method blocks until the dialog is closed.
messages
- error messages and components to be displayedvoid showWarningMsg(java.lang.Object... messages)
This method blocks until the dialog is closed.
messages
- warning messages and components to be displayedboolean showInputMsg(java.lang.Object... messages)
This method blocks until the dialog is closed.
messages
- input messages and components to be displayedjava.lang.String keyStrokeToString(javax.swing.KeyStroke keyStroke)
For example returns " (Ctrl+P)"
for the keystroke of CTRL+P.
keyStroke
- key stroke whose nice string representation to returnvoid setComponentTreeEnabled(java.awt.Component component, boolean enabled)
component
- component to start fromenabled
- value of the enabled property to be setILink linkForAction(java.lang.String text, IAction action)
ILink
which executes the specified action.text
- text of the linkaction
- action to be executed when clicked on the linkILink
which executes the specified actionvoid makeComponentDragScrollable(javax.swing.JComponent component)
If a component is drag-scrollable and the user tries to drag the component, it will be scrolled if it is added to a scroll pane. Also changes the mouse cursor to "MOVE" over this component.
component
- component to be made drag-scrollablejava.awt.Color colorWithAlpha(java.awt.Color c, int alpha)
Color
from the specified color using the specified alpha.c
- color to create a new Color
fromalpha
- alpha to be set to the new colorColor
from the specified color using the specified alphajavax.swing.JLabel renderToLabel(javax.swing.JLabel l, java.lang.Object value, boolean isSelected, boolean hasFocus)
JLabel
.
Can be used where the renderer component is an instance of JLabel
. Designed to be called after the default rendering logic.
Such examples are: DefaultTableCellRenderer
, DefaultListCellRenderer
.
Icon
: renders the icon with no text
IRIcon
: renders the icon with no text
Date
: formats it using ILanguage.formatDateTime(Date)
Double
: formats it using ILanguage.formatNumber(double, int)
with 2 precision
Float
: formats it using ILanguage.formatNumber(double, int)
with 2 precision
Number
: formats it using ILanguage.formatNumber(long)
IPersonNameBean
: formats it using ILanguage.formatPersonName(IPersonNameBean)
HasIcon
: also renders the icon returned by HasIcon.getIcon()
beside the default text
HasRIcon
: also renders the icon returned by HasRIcon.getRicon()
beside the default text
Boolean
: renders a tick icon for true
and a cross icon for false
URL
: renders as link (with proper tool tip)
l
- the renderer labelvalue
- the rendered value objectisSelected
- tells if the rendered value is selectedhasFocus
- tells if the rendered value has focusvoid showSendEmailDialog(java.lang.String to)
This method only returns when the dialog is closed.
to
- initial addresses (list of email addresses)IUtils.checkEmailSettings()
void showSendEmailDialog(java.util.List<java.nio.file.Path> attachmentList)
This method only returns when the dialog is closed.
attachmentList
- default email attachmentsIUtils.checkEmailSettings()
void showSendEmailDialog(java.lang.String title, java.util.List<java.nio.file.Path> attachmentList, java.lang.String to)
This method only returns when the dialog is closed.
title
- dialog titleattachmentList
- default email attachmentsto
- initial addresses (list of email addresses)IUtils.checkEmailSettings()
This API documentation is public and is intended for / allowed to be used by anyone.
Scelight home page: https://sites.google.com/site/scelight/
Scelight is a trademark of András Belicza. Copyright © András Belicza, 2013-2015. All rights reserved.