Class JFactory
-
- All Implemented Interfaces:
@API(since = "5.3", status = API.Status.EXPERIMENTAL) public class JFactory
Enables to apply styles that persist across look and feel updates.
The class provides APIs to configure Swing components so the look is consistent, and it updates the components when Look and Feel changes
Swing API provides no standard components and colors for: small, big components; warning, error styles for labels; and so on
Note: by default JTable comes with fixed
rowHeight
which does not work when the fonts are scaled. So you need to call singleLineRowHeight or configurerowHeight
manually
-
-
Constructor Summary
Constructors Constructor Description JFactory()
-
Method Summary
Modifier and Type Method Description static void
refreshUI()
Re-initializes the current LaF and updates the UI for all the open windows. static void
refreshUI(String className)
Set new look and feel for all the open windows. static JTextArea
tabMovesFocus(JTextArea textArea)
By default JTextArea uses tab
to add tab character, however, sometimes it is desired to usetab
to move focus.static JButton
small(JButton component)
static JLabel
small(JLabel component)
static JTextField
small(JTextField component)
static JCheckBox
small(JCheckBox component)
static JEditableCheckBox
small(JEditableCheckBox component)
static JLabel
big(JLabel component)
static JToolBar
small(JToolBar component)
static JTable
singleLineRowHeight(JTable component)
Updates setRowHeight with the height of a single line. static JLabel
error(JLabel component)
Configures the label to look like warning
.static JLabel
warning(JLabel component)
Configures the label to look like error
.static <T extends JComponent> T
withDynamic(T component, Consumer<out Object> onUpdateUi)
Attaches a configuration action that is executed when Look and Feel changes. static void
updateUi(JComponent c)
-
-
Method Detail
-
refreshUI
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static void refreshUI()
Re-initializes the current LaF and updates the UI for all the open windows.
-
refreshUI
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static void refreshUI(String className)
Set new look and feel for all the open windows.
- Parameters:
className
- look and feel class name
-
tabMovesFocus
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JTextArea tabMovesFocus(JTextArea textArea)
By default JTextArea uses
tab
to add tab character, however, sometimes it is desired to usetab
to move focus.- Parameters:
textArea
- input textarea to configure moving focus on tab
-
small
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JTextField small(JTextField component)
-
small
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JCheckBox small(JCheckBox component)
-
small
@API(since = "5.6", status = API.Status.EXPERIMENTAL) static JEditableCheckBox small(JEditableCheckBox component)
-
small
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JToolBar small(JToolBar component)
-
singleLineRowHeight
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JTable singleLineRowHeight(JTable component)
Updates setRowHeight with the height of a single line. There's no Swing property for
rowHeight
, so each table should be configured individually- Parameters:
component
- input table to configure
-
error
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JLabel error(JLabel component)
Configures the label to look like
warning
.- Parameters:
component
- input label
-
warning
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static JLabel warning(JLabel component)
Configures the label to look like
error
.- Parameters:
component
- input label
-
withDynamic
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static <T extends JComponent> T withDynamic(T component, Consumer<out Object> onUpdateUi)
Attaches a configuration action that is executed when Look and Feel changes.
Note: the action is executed when
withDynamic
is called, and the action is executed even if the new and the old LaFs are the same.- Parameters:
component
- component to updateonUpdateUi
- action to run (immediately and when look and feel changes)
-
updateUi
static void updateUi(JComponent c)
-
-
-
-