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 classrepresenting the OS version numberstatic classan OS version subclass for Windowsstatic classan OS version subclass for macOSstatic classan OS version subclass for Windows -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Fontprotected intstatic final Stringstatic final Stringstatic final Stringuser specified "none" name @since 1.7static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringchanged to nimbus-flat forNimbusLookAndFeelCustomFlatstatic final Stringstatic final Stringstatic final Stringprotected UIManagerUtil.OsVersionprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckMenuModifiersMask(int constKey, int testedMods) static Stringrun a process with the arguments.intstatic UIManagerUtilprotected Class<?> static StringgetLookAndFeelProp(String prop) static StringgetLookAndFeelSpecial(String value) floatgetScaledSizeFloat(float n) intgetScaledSizeInt(int n) (changed to useTextField.backgroundfromTextPane.backgrounddue to GTK always returns white)static UIManagerUtil.OsVersionbooleanbooleaninstall com.formdev.flatlaf.FlatDarkLaf or .FlatLightLaf by reflection.booleanbooleanselectLookAndFeelDefault(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.voidsetIconSize(int iconSize) voidsetLookAndFeel(String lookAndFeelClass) #prop:p=> rewrite the param byselectLookAndFeelFromProperty(String, boolean)with (p,true); the method sets the property with#nonefor preventing multiple installation of same LAF.voidcalled fromsetLookAndFeel(String)and apply some customization not depending on LAF.voidcalled fromsetLookAndFeel(String)and apply some customizationprotected ColoruiManagerColor(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.backgroundfromTextPane.backgrounddue 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#nonefor 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,defaultordefault-no-darklaf=>selectLookAndFeelDefault(boolean)with (falseifdefault-no-darklaf, otherwisetrue)darklaforflatlaf=>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:,#noneor#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
-
checkMenuModifiersMask
public static boolean checkMenuModifiersMask(int constKey, int testedMods) - Parameters:
constKey-InputEvent.SHIFT_DOWN_MASK,InputEvent.CTRL_DOWN_MASK,InputEvent.ALT_DOWN_MASK,InputEvent.META_DOWN_MASKtestedMods- tested modifiers keys- Returns:
- true if constKey has testedMods
- Since:
- 1.8
-
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
-