public class SwingHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MIN_FONT_SIZE
The default value for a minimal font size when adjusting font sizes.
|
Constructor and Description |
---|
SwingHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
adjustFontSizes(int plusminus)
Adjust all font sizes used in the application.
|
static void |
adjustFontSizes(int plusminus,
java.awt.Component... updateRoots)
Adjust all font sizes used in the application.
|
static void |
adjustFontSizes(int plusminus,
java.awt.Component updateRoot)
Adjust all font sizes used in the application.
|
static void |
adjustFontSizes(int plusminus,
int allowedMinSize)
Adjust all font sizes used in the application.
|
static void |
adjustFontSizes(int plusminus,
int allowedMinSize,
java.awt.Component... updateRoots)
Adjust all font sizes used in the application.
|
static void |
adjustFontSizes(int plusminus,
int allowedMinSize,
java.awt.Component updateRoot)
Adjust all font sizes used in the application.
|
static void |
enableHiDpiSupport(java.awt.Window mainWindow,
java.awt.Component... moreRoots)
Enable high DPI support for the given window.
|
static int |
getAccumulatedFontSizeChanges()
Get the accumulated font size changes.
|
static java.awt.Rectangle |
getDrawableViewport(javax.swing.JComponent comp)
Get the inner rectangle of a Swing component which is available for drawing.
|
static int |
getMinUiFontSize()
Get the minimal size used in the UI fonts.
|
static javax.swing.Icon |
loadIconResource(java.lang.String resourcePath)
Load a potentially scalable icon.
|
static int |
setupDefaultHiDpi()
Setup default high DPI settings.
|
static int |
setupDefaultHiDpi(java.awt.GraphicsConfiguration config)
Setup default high DPI settings.
|
static void |
updateUI(java.awt.Component component)
Calls the updateUI() method on swing components recursively.
|
public static final int DEFAULT_MIN_FONT_SIZE
public static void adjustFontSizes(int plusminus)
plusminus
- how to adjust, if positive fonts used become larger, if negative smallerpublic static void adjustFontSizes(int plusminus, int allowedMinSize)
plusminus
- how to adjust, if positive fonts used become larger, if negative smallerallowedMinSize
- the minimal font size result when shrinkingpublic static void adjustFontSizes(int plusminus, java.awt.Component updateRoot)
plusminus
- how to adjust, if positive fonts used become larger, if negative smallerupdateRoot
- because for some reason the components don't update automatically,
here a root component may be added which will be explicitely updated using
the updateUI(java.awt.Component)
methodpublic static void adjustFontSizes(int plusminus, int allowedMinSize, java.awt.Component updateRoot)
plusminus
- how to adjust, if positive fonts used become larger, if negative smallerallowedMinSize
- the minimal font size result when shrinkingupdateRoot
- because for some reason the components don't update automatically,
here a root component may be added which will be explicitly updated using
the updateUI(java.awt.Component)
methodpublic static void adjustFontSizes(int plusminus, java.awt.Component... updateRoots)
plusminus
- how to adjust, if positive fonts used become larger, if negative smallerupdateRoots
- because for some reason the components don't update automatically,
here root components may be added which will be explicitly updated using
the updateUI(java.awt.Component)
methodpublic static void adjustFontSizes(int plusminus, int allowedMinSize, java.awt.Component... updateRoots)
plusminus
- how to adjust, if positive fonts used become larger, if negative smallerallowedMinSize
- the minimal font size result when shrinkingupdateRoots
- because for some reason the components don't update automatically,
here root components may be added which will be explicitly updated using
the updateUI(java.awt.Component)
methodpublic static int getMinUiFontSize()
public static void updateUI(java.awt.Component component)
component
- root componentpublic static int getAccumulatedFontSizeChanges()
public static void enableHiDpiSupport(java.awt.Window mainWindow, java.awt.Component... moreRoots)
mainWindow
- application's main windowmoreRoots
- more root components for recursive enablementpublic static int setupDefaultHiDpi()
public static int setupDefaultHiDpi(java.awt.GraphicsConfiguration config)
config
- graphics configuration used for setuppublic static javax.swing.Icon loadIconResource(java.lang.String resourcePath)
resourcePath
- internal resource path to imagepublic static java.awt.Rectangle getDrawableViewport(javax.swing.JComponent comp)
comp
- component for which the draw rectangle is requested