public abstract class Utils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
centerWindow(Window window,
Window reference)
Deprecated.
|
static Icon |
createIcon(URL path,
float sizeRatio) |
static Icon |
createIcon(URL path,
int size)
Gets an icon by its URL and resize it if needed.
|
static String |
getLFClassFromName(String lookAndFeelName)
Converts a look and feel name to its class name.
|
static Window |
getOwnerWindow(Component component)
Gets the window which contains a component.
|
static MouseListener |
getToolTipAdapter(int initialDelay,
int dismissDelay,
int reshowDelay)
Returns a utility MouseListener to set custom toolTip delays on
component.
|
static boolean |
isVisible(Rectangle rec) |
static int |
packColumn(JTable table,
int colIndex,
int margin)
Sets the preferred width of the visible column specified by vColIndex.
|
static void |
packColumns(JTable table,
int margin)
Packs the columns of a JTable.
|
static void |
restoreState(Frame frame,
Preferences prefs)
Restores the state (size, position, maximized/minimized state) of a frame.
|
static void |
saveState(Frame frame,
Preferences prefs)
Saves the state (size, position, maximized/minimized state) of a frame.
|
static void |
setSafeBounds(Frame frame,
Rectangle bounds)
Carefully sets the rectangle of a frame.
|
public static Window getOwnerWindow(Component component)
component
- the component@Deprecated public static void centerWindow(Window window, Window reference)
window
- The window to centerreference
- The reference windowWindow.setLocationRelativeTo(Component)
public static void packColumns(JTable table, int margin)
table
- The Jtable to packmargin
- the margin in pixelspackColumn(JTable, int, int)
public static int packColumn(JTable table, int colIndex, int margin)
table
- a tablecolIndex
- the column index (model based not view based)margin
- The cells marginpublic static Icon createIcon(URL path, int size)
path
- The absolute icon path resourcesize
- the required sizepublic static MouseListener getToolTipAdapter(int initialDelay, int dismissDelay, int reshowDelay)
component.addMouseListener(Utils.getToolTipAdpater(...))
initialDelay
- see javax.swing.ToolTipManager documentation. A negative int
to use the default delay.dismissDelay
- see javax.swing.ToolTipManager documentation. A negative int
to use the default delay. Zero to disable the tooltip.reshowDelay
- see javax.swing.ToolTipManager documentation. A negative int
to use the default delay.public static String getLFClassFromName(String lookAndFeelName)
lookAndFeelName
- The name of the look and feelpublic static void saveState(Frame frame, Preferences prefs)
frame
- The frame we want to save the stateprefs
- The preferences where to save the staterestoreState(Frame, Preferences)
public static void restoreState(Frame frame, Preferences prefs)
saveState(java.awt.Frame, java.util.prefs.Preferences)
.frame
- The frame we want to save the stateprefs
- The preferences where to save the statesaveState(Frame, Preferences)
public static void setSafeBounds(Frame frame, Rectangle bounds)
frame
- The frame to resize/movebounds
- The future frame rectangle. If its height or its width is < 0, the frame is maximized vertically/horizontally.
If it is not visible on the current available screens, the frame's location is set to the middle of the default screen.public static boolean isVisible(Rectangle rec)
Copyright © 2022. All rights reserved.