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
Nested ClassesModifier and TypeClassDescriptionstatic 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
FieldsModifier and TypeFieldDescriptionprotected Font
protected int
static final String
static final String
static final String
user specified "none" name @since 1.7static 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
changed to nimbus-flat forNimbusLookAndFeelCustomFlat
static final String
static final String
static final String
protected UIManagerUtil.OsVersion
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
run a process with the arguments.int
static UIManagerUtil
protected Class
<?> static String
getLookAndFeelProp
(String prop) static String
getLookAndFeelSpecial
(String value) float
getScaledSizeFloat
(float n) int
getScaledSizeInt
(int n) (changed to useTextField.background
fromTextPane.background
due to GTK always returns white)static UIManagerUtil.OsVersion
boolean
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 Flatlaf byinstallLookAndFeelFlatlaf()
if the parameter is true if macOS environment andUIManagerUtil.OsVersion.isDarkTheme()
=false, useUIManager.getSystemLookAndFeelClassName()
, otherwise,selectLookAndFeelFromSpecialName(String)
with"nimbus-flat"
selectLookAndFeelFromProperty
(String prop, boolean updateProp) process LAF resolution for "#prop:p"."metal"
=> the class name ofMetalLookAndFeel
"nimbus"
=> the class name ofNimbusLookAndFeel
"system"
=>UIManager.getSystemLookAndFeelClassName()
null
,""
or"default"
=>"default"
for later processes byselectLookAndFeelDefault(boolean)
"darklaf"
=>"darklaf"
or"flatlaf"
for later processes byinstallLookAndFeelFlatlaf()
"default-no-darklaf"
=>"default-no-darklaf"
for later processes.void
setIconSize
(int iconSize) void
setLookAndFeel
(String lookAndFeelClass) #prop:p
=> rewrite the param byselectLookAndFeelFromProperty(String, boolean)
with (p,true); the method sets the property with#none
for preventing multiple installation of same LAF.void
called fromsetLookAndFeel(String)
and apply some customization not depending on LAF.void
called fromsetLookAndFeel(String)
and apply some customizationprotected Color
uiManagerColor
(String... names)
-
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_FLATLAF
- Since:
- 1.7
- See Also:
-
LOOK_AND_FEEL_VALUE_NIMBUS_CUSTOM
changed to nimbus-flat forNimbusLookAndFeelCustomFlat
- Since:
- 1.6.1
- See Also:
-
LOOK_AND_FEEL_VALUE_NIMBUS_CUSTOM_LIGHT
- Since:
- 1.7
- See Also:
-
LOOK_AND_FEEL_VALUE_NIMBUS_CUSTOM_DARK
- Since:
- 1.7
- See Also:
-
LOOK_AND_FEEL_DEFAULT
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_NONE
- Since:
- 1.3
- See Also:
-
LOOK_AND_FEEL_NONE_NAME
user specified "none" name @since 1.7- See Also:
-
-
Constructor Details
-
UIManagerUtil
public UIManagerUtil()
-
-
Method Details
-
getInstance
-
getConsoleFont
-
getLabelFont
-
getEditorPaneFont
-
getTableFocusCellHighlightBorder
-
uiManagerColor
-
toConcreteColor
-
getLabelForeground
-
getLabelBackground
-
getLabelDisabledForeground
-
getTextPaneSelectionBackground
-
getTextPaneSelectionForeground
-
getTextPaneForeground
- Returns:
- the text pane foreground
- Since:
- 1.2
-
getTextPaneBackground
(changed to useTextField.background
fromTextPane.background
due to GTK always returns white)- 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
=> rewrite the param byselectLookAndFeelFromProperty(String, boolean)
with (p,true); the method sets the property with#none
for preventing multiple installation of same LAF. Continues with the following steps.#special:v
=> rewrite the param byselectLookAndFeelFromSpecialName(String)
with (v). Continues with the following steps.#default
,default
ordefault-no-darklaf
=>selectLookAndFeelDefault(boolean)
with (false
ifdefault-no-darklaf
, otherwisetrue
)darklaf
orflatlaf
=>installLookAndFeelFlatlaf()
#none
=> nothing to donull
=> nothing to do- otherwise => treats the value as a LAF class-name; loading by
UIManager.setLookAndFeel(String)
. If the class-name isUIManager.getSystemLookAndFeelClassName()
,setLookAndFeelSystemFix()
.
setLookAndFeelFix()
.- Parameters:
lookAndFeelClass
- the LAF class name or a special configuration name starting from#prop:
,#none
or#default
- Since:
- 1.2
-
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 sets the prop to#none
- Returns:
- a resolved class-name or a special value from the property or null
- Since:
- 1.3
-
selectLookAndFeelFromSpecialName
-
"metal"
=> the class name ofMetalLookAndFeel
-
"nimbus"
=> the class name ofNimbusLookAndFeel
-
"system"
=>UIManager.getSystemLookAndFeelClassName()
-
null
,""
or"default"
=>"default"
for later processes byselectLookAndFeelDefault(boolean)
-
"darklaf"
=>"darklaf"
or"flatlaf"
for later processes byinstallLookAndFeelFlatlaf()
-
"default-no-darklaf"
=>"default-no-darklaf"
for later processes. same as"default"
except for no darklaf installing -
"nimbus-flat"
=>NimbusLookAndFeelCustomFlat
-
"nimbus-flat-light"
=>NimbusLookAndFeelCustomFlat.NimbusLookAndFeelCustomFlatLight
-
"nimbus-flat-dark"
=>NimbusLookAndFeelCustomFlat.NimbusLookAndFeelCustomFlatDark
-
"none
=>"#none"
- 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
- See Also:
-
-
selectLookAndFeelDefault
process default behavior for the "#default" configuration- try to load Flatlaf by
installLookAndFeelFlatlaf()
if the parameter is true - if macOS environment and
UIManagerUtil.OsVersion.isDarkTheme()
=false, useUIManager.getSystemLookAndFeelClassName()
, - otherwise,
selectLookAndFeelFromSpecialName(String)
with"nimbus-flat"
- Parameters:
tryDarklaf
- if true, callinstallLookAndFeelFlatlaf()
- Returns:
- a resolved LAF class-name or null
- Since:
- 1.3
- try to load Flatlaf by
-
installLookAndFeelDarklaf
public boolean installLookAndFeelDarklaf()- See Also:
-
installLookAndFeelFlatlaf
public boolean installLookAndFeelFlatlaf()install com.formdev.flatlaf.FlatDarkLaf or .FlatLightLaf by reflection. Note: currently supporting flatlaf:2.0.1--3.1.1 Since v3, flatlaf supports com.formdev.flatlaf.themes.{FlatMacDarkLaf, FlatMacLightLaf}.- Returns:
- true if the flatlaf is installed
- Since:
- 1.3
-
getLookAndFeelDarkLafClass
- Throws:
ClassNotFoundException
-
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
-