Package org.apache.jorphan.gui
Class JFactory
java.lang.Object
org.apache.jorphan.gui.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(JTable)
or configure rowHeight manually
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JLabelstatic JLabelConfigures the label to look likewarning.static voidRe-initializes the current LaF and updates the UI for all the open windows.static voidSet new look and feel for all the open windows.static JTablesingleLineRowHeight(JTable component) UpdatesJTable.setRowHeight(int)with the height of a single line.static JButtonstatic JCheckBoxstatic JLabelstatic JTextFieldsmall(JTextField component) static JToolBarstatic org.apache.jorphan.gui.JEditableCheckBoxsmall(org.apache.jorphan.gui.JEditableCheckBox component) static JTextAreatabMovesFocus(JTextArea textArea) By defaultJTextAreausestabto add tab character, however, sometimes it is desired to usetabto move focus.static voidstatic JLabelConfigures the label to look likeerror.static <T extends JComponent>
TwithDynamic(T component, Consumer<? super T> onUpdateUi) Attaches a configuration action that is executed when Look and Feel changes.
-
Constructor Details
-
JFactory
public JFactory()
-
-
Method Details
-
refreshUI
@API(since="5.3", status=EXPERIMENTAL) public static void refreshUI()Re-initializes the current LaF and updates the UI for all the open windows. -
refreshUI
Set new look and feel for all the open windows.- Parameters:
className- look and feel class name
-
tabMovesFocus
By defaultJTextAreausestabto add tab character, however, sometimes it is desired to usetabto move focus.- Parameters:
textArea- input textarea to configure moving focus on tab- Returns:
- input textarea (for fluent APIs)
-
small
-
small
-
small
-
small
-
small
@API(since="5.6", status=EXPERIMENTAL) public static org.apache.jorphan.gui.JEditableCheckBox small(org.apache.jorphan.gui.JEditableCheckBox component) -
big
-
small
-
singleLineRowHeight
UpdatesJTable.setRowHeight(int)with the height of a single line. There's no Swing property forrowHeight, so each table should be configured individually- Parameters:
component- input table to configure- Returns:
- input component (for fluent APIs)
-
error
Configures the label to look likewarning.- Parameters:
component- input label- Returns:
- input label (for fluent APIs)
-
warning
Configures the label to look likeerror.- Parameters:
component- input label- Returns:
- input label (for fluent APIs)
-
withDynamic
@API(since="5.3", status=EXPERIMENTAL) public static <T extends JComponent> T withDynamic(T component, Consumer<? super T> onUpdateUi) Attaches a configuration action that is executed when Look and Feel changes.Note: the action is executed when
withDynamicis called, and the action is executed even if the new and the old LaFs are the same.- Type Parameters:
T- type of the component- Parameters:
component- component to updateonUpdateUi- action to run (immediately and when look and feel changes)- Returns:
- input component (e.g. for fluent APIs)
-
updateUi
-