public class SwingTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addAutoSelectionOnFocusGain(javax.swing.text.JTextComponent textComponent)
Adds focus and mouse listeners to the given
textComponent that will
select all its text when it gains focus by transfer. |
static java.awt.event.AdjustmentListener |
createAdjustmentListenerUpdatingScrollPaneViewToolTip(javax.swing.JScrollPane scrollPane)
Returns a scroll bar adjustment listener bound to the given
scrollPane view
that updates view tool tip when its vertical scroll bar is adjusted. |
static java.awt.Cursor |
createCustomCursor(java.net.URL smallCursorImageUrl,
java.net.URL largeCursorImageUrl,
float xCursorHotSpot,
float yCursorHotSpot,
java.lang.String cursorName,
java.awt.Cursor defaultCursor)
Returns a new custom cursor.
|
static javax.swing.JScrollPane |
createScrollPane(javax.swing.JComponent component)
Returns a scroll pane containing the given
component
that always displays scroll bars under Mac OS X. |
static javax.swing.JPanel |
createTitledPanel(java.lang.String title)
Returns a new panel with a border and the given
title |
static void |
deselectAllRadioButtons(javax.swing.JRadioButton... radioButtons)
Forces radio buttons to be deselected even if they belong to a button group.
|
static <T extends java.awt.Component> |
findChildren(javax.swing.JComponent parent,
java.lang.Class<T> childrenClass)
Returns the children of a component of the given class.
|
static javax.swing.border.Border |
getDropableComponentBorder()
Returns the border of a component where a user may drop objects.
|
static java.awt.Dimension |
getImageSizeInPixels(Content image)
Returns
image size in pixels. |
static java.lang.String |
getLocalizedLabelText(UserPreferences preferences,
java.lang.Class<?> resourceClass,
java.lang.String resourceKey,
java.lang.Object... resourceParameters)
Returns a localized text for menus items and labels depending on the system.
|
static java.awt.image.BufferedImage |
getPatternImage(TextureImage pattern,
java.awt.Color backgroundColor,
java.awt.Color foregroundColor)
Returns the image matching a given pattern.
|
static float |
getResolutionScale()
Returns a scale factor used to adapt user interface items to screen resolution.
|
static javax.swing.ImageIcon |
getScaledImageIcon(java.net.URL imageUrl)
Returns an image icon scaled according to the value returned by
getResolutionScale() . |
static java.awt.Stroke |
getStroke(float thickness,
Polyline.CapStyle capStyle,
Polyline.JoinStyle joinStyle,
Polyline.DashStyle dashStyle)
Returns the line stroke matching the given line styles.
|
static void |
hideDisabledMenuItems(javax.swing.JPopupMenu popupMenu)
Adds a listener that will update the given popup menu to hide disabled menu items.
|
static void |
installFocusBorder(javax.swing.JComponent component)
Updates the border of
component with an empty border
changed to a colored border when it will gain focus. |
static boolean |
isRectangleVisibleAtScreen(java.awt.Rectangle rectangle)
Returns
true if the given rectangle is fully visible at screen. |
static boolean |
isToolTipShowing()
Returns
true if a tool tip is showing. |
static void |
requestFocusInWindow(javax.swing.JComponent focusedComponent)
Requests the focus for the given component.
|
static int |
showConfirmDialog(javax.swing.JComponent parentComponent,
javax.swing.JComponent messageComponent,
java.lang.String title,
javax.swing.JComponent focusedComponent)
Displays
messageComponent in a modal dialog box, giving focus to one of its components. |
static boolean |
showDocumentInBrowser(java.net.URL url)
Attempts to display the given
url in a browser and returns true
if it was done successfully. |
static void |
showMessageDialog(javax.swing.JComponent parentComponent,
javax.swing.JComponent messageComponent,
java.lang.String title,
int messageType,
javax.swing.JComponent focusedComponent)
Displays
messageComponent in a modal dialog box, giving focus to one of its components. |
static void |
showMessageDialog(javax.swing.JComponent parentComponent,
java.lang.Object message,
java.lang.String title,
int messageType)
Displays
message in a modal dialog box. |
static int |
showOptionDialog(java.awt.Component parentComponent,
java.lang.String message,
java.lang.String title,
int optionType,
int messageType,
java.lang.Object[] options,
java.lang.Object initialValue)
Displays message in a dialog box, possibly adjusting font size if required.
|
static void |
showSplashScreenWindow(java.net.URL imageUrl)
Displays the image referenced by
imageUrl in an AWT window
disposed once an instance of JFrame or JDialog is displayed. |
static void |
updateSwingResourceLanguage()
Updates the Swing resource bundles in use from the default Locale and class loader.
|
static void |
updateSwingResourceLanguage(UserPreferences preferences)
Updates the Swing resource bundles in use from the preferences Locale and the class loaders of preferences.
|
public static void installFocusBorder(javax.swing.JComponent component)
component
with an empty border
changed to a colored border when it will gain focus.
If the component
component is the child of a JViewPort
instance this border will be installed on its scroll pane parent.public static void updateSwingResourceLanguage()
public static void updateSwingResourceLanguage(UserPreferences preferences)
public static java.lang.String getLocalizedLabelText(UserPreferences preferences, java.lang.Class<?> resourceClass, java.lang.String resourceKey, java.lang.Object... resourceParameters)
public static void addAutoSelectionOnFocusGain(javax.swing.text.JTextComponent textComponent)
textComponent
that will
select all its text when it gains focus by transfer.public static void deselectAllRadioButtons(javax.swing.JRadioButton... radioButtons)
public static int showConfirmDialog(javax.swing.JComponent parentComponent, javax.swing.JComponent messageComponent, java.lang.String title, javax.swing.JComponent focusedComponent)
messageComponent
in a modal dialog box, giving focus to one of its components.public static void showMessageDialog(javax.swing.JComponent parentComponent, java.lang.Object message, java.lang.String title, int messageType)
message
in a modal dialog box.public static void showMessageDialog(javax.swing.JComponent parentComponent, javax.swing.JComponent messageComponent, java.lang.String title, int messageType, javax.swing.JComponent focusedComponent)
messageComponent
in a modal dialog box, giving focus to one of its components.public static int showOptionDialog(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, int optionType, int messageType, java.lang.Object[] options, java.lang.Object initialValue)
public static void requestFocusInWindow(javax.swing.JComponent focusedComponent)
public static java.awt.image.BufferedImage getPatternImage(TextureImage pattern, java.awt.Color backgroundColor, java.awt.Color foregroundColor)
public static javax.swing.border.Border getDropableComponentBorder()
public static void showSplashScreenWindow(java.net.URL imageUrl)
imageUrl
in an AWT window
disposed once an instance of JFrame
or JDialog
is displayed.
If the imageUrl
is incorrect, nothing happens.public static javax.swing.JPanel createTitledPanel(java.lang.String title)
title
public static javax.swing.JScrollPane createScrollPane(javax.swing.JComponent component)
component
that always displays scroll bars under Mac OS X.public static java.awt.event.AdjustmentListener createAdjustmentListenerUpdatingScrollPaneViewToolTip(javax.swing.JScrollPane scrollPane)
scrollPane
view
that updates view tool tip when its vertical scroll bar is adjusted.public static boolean isToolTipShowing()
true
if a tool tip is showing.public static void hideDisabledMenuItems(javax.swing.JPopupMenu popupMenu)
public static boolean showDocumentInBrowser(java.net.URL url)
url
in a browser and returns true
if it was done successfully.public static <T extends java.awt.Component> java.util.List<T> findChildren(javax.swing.JComponent parent, java.lang.Class<T> childrenClass)
public static boolean isRectangleVisibleAtScreen(java.awt.Rectangle rectangle)
true
if the given rectangle is fully visible at screen.public static java.awt.Cursor createCustomCursor(java.net.URL smallCursorImageUrl, java.net.URL largeCursorImageUrl, float xCursorHotSpot, float yCursorHotSpot, java.lang.String cursorName, java.awt.Cursor defaultCursor)
public static java.awt.Dimension getImageSizeInPixels(Content image) throws java.io.IOException
image
size in pixels.null
if the information isn't given in the meta data of the imagejava.io.IOException
public static java.awt.Stroke getStroke(float thickness, Polyline.CapStyle capStyle, Polyline.JoinStyle joinStyle, Polyline.DashStyle dashStyle)
public static float getResolutionScale()
public static javax.swing.ImageIcon getScaledImageIcon(java.net.URL imageUrl)
getResolutionScale()
.
© Copyright 2024 Space Mushrooms
Distributed under GNU General Public License