java.lang.Object
org.autogui.swing.util.UIManagerUtil
a support class with
UIManager
.
the main purpose of the class is providing default settings of UI resources and sizes
in order to support HiDPI environments.
int size = UIManager.getInstance().getScaledSizeForInt(12); ...
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
a subclass ofNimbusLookAndFeel
with changing colors as suitable for modern Windows.static class
representing the OS version numberstatic class
an OS version subclass for Windowsstatic class
an OS version subclass for macOSstatic class
an OS version subclass for Windows -
Field Summary
Modifier and TypeFieldDescriptionprotected Font
protected int
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected UIManagerUtil.OsVersion
protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
run a process with the arguments.int
static UIManagerUtil
static String
getLookAndFeelProp
(String prop) static String
getLookAndFeelSpecial
(String value) float
getScaledSizeFloat
(float n) int
getScaledSizeInt
(int n) static UIManagerUtil.OsVersion
boolean
install com.formdev.flatlaf.FlatDarkLaf or .FlatLightLaf by reflection.boolean
boolean
selectLookAndFeelDefault
(boolean tryDarklaf) process default behavior for the "#default" configuration try to load Darklaf byinstallLookAndFeelDarkLaf()
if the parameter is true if macOS environment, useUIManager.getSystemLookAndFeelClassName()
if Windows environment, use "nimbus" (due to failure of size on HiDPI) if the GDK_SCALE env is set, use "metal" otherwise, nothing to doselectLookAndFeelFromProperty
(String prop, boolean updateProp) process LAF resolution for "#prop:p"."metal" =>MetalLookAndFeel
"nimbus" =>NimbusLookAndFeel
"system" =>UIManager.getSystemLookAndFeelClassName()
null, "" or "default" => "default" for later processes byselectLookAndFeelDefault(boolean)
"darklaf" => "darklaf" for later processes byinstallLookAndFeelDarkLaf()
"default-no-darklaf" => "default-no-darklaf" for later processes.void
setIconSize
(int iconSize) void
setLookAndFeel
(String lookAndFeelClass) #prop:p =>selectLookAndFeelFromProperty(String, boolean)
with (p,true) #special:v =>selectLookAndFeelFromSpecialName(String)
with (v) #default or default =>selectLookAndFeelDefault(boolean)
darklaf =>installLookAndFeelDarkLaf()
#none => nothing to do.void
called fromsetLookAndFeel(String)
and apply some customization not depending on LAF.void
called fromsetLookAndFeel(String)
and apply some customization
-
Field Details
-
consoleFont
-
iconSize
protected int iconSize -
systemLaf
protected boolean systemLaf -
osVersion
- Since:
- 1.2
-
LOOK_AND_FEEL_PROP_HEAD
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_SPECIAL_HEAD
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_PROP_DEFAULT
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_METAL
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_NIMBUS
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_SYSTEM
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_DEFAULT
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_DEFAULT_NO_DARKLAF
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_DARKLAF
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_VALUE_NIMBUS_CUSTOM
- Since:
- 1.6.1
- See Also:
-
LOOK_AND_FEEL_DEFAULT
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_NONE
- Since:
- 1.3
- See Also:
-
-
Constructor Details
-
UIManagerUtil
public UIManagerUtil()
-
-
Method Details
-
getInstance
-
getConsoleFont
-
getLabelFont
-
getEditorPaneFont
-
getTableFocusCellHighlightBorder
-
getLabelForeground
-
getLabelBackground
-
getLabelDisabledForeground
-
getTextPaneSelectionBackground
-
getTextPaneSelectionForeground
-
getTextPaneForeground
- Returns:
- the text pane foreground
- Since:
- 1.2
-
getTextPaneBackground
- Returns:
- the text pane background
- Since:
- 1.2
-
getFocusColor
-
getMenuDisabledForeground
-
getTableAlternateRowColor
- Returns:
- Table.alternateRowColor or null
- Since:
- 1.2
-
getTableDropCellBackground
- Returns:
- Table.dropCellBackground or null
- Since:
- 1.2
-
getTableDropCellForeground
- Returns:
- Table.dropCellForeground or null
- Since:
- 1.2
-
getTableFocusCellBackground
- Returns:
- Table.focusCellBackground or null
- Since:
- 1.2
-
getTableBackground
- Returns:
- Table.background or null
- Since:
- 1.2
-
getTableFocusCellForeground
- Returns:
- Table.focusCellForeground or null
- Since:
- 1.2
-
getListAlternateRowColor
- Returns:
- List.alternateRowColor or null
- Since:
- 1.2
-
getListDropCellBackground
- Returns:
- List.dropCellBackground or null
- Since:
- 1.2
-
getListDropCellForeground
- Returns:
- List.dropCellForeground or null
- Since:
- 1.2
-
getListFocusCellBackground
- Returns:
- List.focusCellBackground or null
- Since:
- 1.2
-
getListFocusCellForeground
- Returns:
- List.focusCellForeground or null
- Since:
- 1.2
-
getIconSize
public int getIconSize()- Returns:
- 32 or label font height x2.1
-
setIconSize
public void setIconSize(int iconSize) - Parameters:
iconSize
- the new icon size: font height x2.1- Since:
- 1.2
-
getScaledSizeInt
public int getScaledSizeInt(int n) -
getScaledSizeFloat
public float getScaledSizeFloat(float n) -
setLookAndFeel
- #prop:p =>
selectLookAndFeelFromProperty(String, boolean)
with (p,true) - #special:v =>
selectLookAndFeelFromSpecialName(String)
with (v) - #default or default =>
selectLookAndFeelDefault(boolean)
- darklaf =>
installLookAndFeelDarkLaf()
- #none => nothing to do. it also clears the "autogui.laf" property for preventing changing LAF by the user
- null => nothing to do
- otherwise => treats the value as a LAF class-name
- Parameters:
lookAndFeelClass
- the LAF class name or a special configuration name starting from#prop:
,#none
or#default
- Since:
- 1.2
- #prop:p =>
-
selectLookAndFeelFromProperty
process LAF resolution for "#prop:p". it reads a LAF class-name from the system property "p". The value of p can be a special name resolved byselectLookAndFeelFromSpecialName(String)
or a concrete LAF class-name .The default prop is "autogui.laf". This means that the system accepts the property with a special name like "-Dautogui.laf=system" and it can resolve the property with an actual class-name which will be read by the swing system.
- Parameters:
prop
- a nullable property nameupdateProp
- if true it updates the prop specified by the laf with the resolved concrete class-name For "darklaf", it clears the property- Returns:
- a resolved class-name from the property or null
- Since:
- 1.3
-
selectLookAndFeelFromSpecialName
- "metal" =>
MetalLookAndFeel
- "nimbus" =>
NimbusLookAndFeel
- "system" =>
UIManager.getSystemLookAndFeelClassName()
- null, "" or "default" => "default" for later processes by
selectLookAndFeelDefault(boolean)
- "darklaf" => "darklaf" for later processes by
installLookAndFeelDarkLaf()
- "default-no-darklaf" => "default-no-darklaf" for later processes. same as "default" except for no darklaf installing
- "nimbus-custom" =>
UIManagerUtil.NimbusLookAndFeelCustomLight
- otherwise => name as is
- Parameters:
name
- a special name or a class-name- Returns:
- resolved class name or still special name for some names
- Since:
- 1.3
- "metal" =>
-
selectLookAndFeelDefault
process default behavior for the "#default" configuration- try to load Darklaf by
installLookAndFeelDarkLaf()
if the parameter is true - if macOS environment, use
UIManager.getSystemLookAndFeelClassName()
- if Windows environment, use "nimbus" (due to failure of size on HiDPI)
- if the GDK_SCALE env is set, use "metal"
- otherwise, nothing to do
- Parameters:
tryDarklaf
- if true, callinstallLookAndFeelDarkLaf()
- Returns:
- a resolved LAF class-name or null
- Since:
- 1.3
- try to load Darklaf by
-
installLookAndFeelDarkLaf
public boolean installLookAndFeelDarkLaf()install com.formdev.flatlaf.FlatDarkLaf or .FlatLightLaf by reflection. Note: currently supporting flatlaf:2.0.1--2.1- Returns:
- true if the darklaf is installed
- Since:
- 1.3
-
getLookAndFeelProp
- Parameters:
prop
- a property name- Returns:
- "#prop:"+prop
- Since:
- 1.3
-
getLookAndFeelSpecial
- Parameters:
value
- a special name- Returns:
- "#special:"+value
- Since:
- 1.4
-
setLookAndFeelSystemFix
public void setLookAndFeelSystemFix()called fromsetLookAndFeel(String)
and apply some customization- Since:
- 1.2
-
setLookAndFeelFix
public void setLookAndFeelFix()called fromsetLookAndFeel(String)
and apply some customization not depending on LAF.- Since:
- 1.6
-
isTableCustomHighlighting
public boolean isTableCustomHighlighting()- Returns:
- if macOS native UI, true for enabling table-view custom highlighting
- Since:
- 1.2
-
isTabbedPaneAllowOpaqueComponent
public boolean isTabbedPaneAllowOpaqueComponent()- Returns:
- if macOS native UI, true for allowing transparent tab-component
- Since:
- 1.2
-
initOsVersion
- Returns:
- a created OS version of the runtime
- Since:
- 1.2
-
getOsVersion
- Returns:
- the OS version of the runtime
- Since:
- 1.2
-
command
run a process with the arguments. The timeout for waiting outputs is 10 secs.- Parameters:
args
- the command arguments- Returns:
- the standard output of the process. the method throws an exception if failed
- Since:
- 1.4
-