org.apache.jorphan.gui

## Class JFactory

- java.lang.Object
- - org.apache.jorphan.gui.JFactory

-     @API(since="5.3",
           status=EXPERIMENTAL)
      public class JFactory
      extends Object

  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
    Constructor and Description
    `JFactory()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static JLabel` | `big(JLabel component)`
    `static JLabel` | `error(JLabel component)` Configures the label to look like `warning`.
    `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 JTable` | `singleLineRowHeight(JTable component)` Updates `JTable.setRowHeight(int)` with the height of a single line.
    `static JButton` | `small(JButton component)`
    `static JCheckBox` | `small(JCheckBox component)`
    `static JLabel` | `small(JLabel component)`
    `static JTextField` | `small(JTextField component)`
    `static JToolBar` | `small(JToolBar component)`
    `static JTextArea` | `tabMovesFocus(JTextArea textArea)` By default `JTextArea` uses `tab` to add tab character, however, sometimes it is desired to use `tab` to move focus.
    `static void` | `updateUi(JComponent c)`
    `static JLabel` | `warning(JLabel component)` Configures the label to look like `error`.
    `static <T extends JComponent> T` | `withDynamic(T component, Consumer<T> onUpdateUi)` Attaches a configuration action that is executed when Look and Feel changes.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JFactory

          public JFactory()

  - ### Method Detail

    - #### 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

          @API(since="5.3",
               status=EXPERIMENTAL)
          public 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=EXPERIMENTAL)
          public static JTextArea tabMovesFocus(JTextArea textArea)

      By default `JTextArea` uses `tab` to add tab character, however, sometimes it is desired to use `tab` to move focus.
      Parameters:
        `textArea` - input textarea to configure moving focus on tab
      Returns:
        input textarea (for fluent APIs)

    - #### small

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JButton small(JButton component)

    - #### small

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JLabel small(JLabel component)

    - #### small

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JTextField small(JTextField component)

    - #### small

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JCheckBox small(JCheckBox component)

    - #### big

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JLabel big(JLabel component)

    - #### small

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JToolBar small(JToolBar component)

    - #### singleLineRowHeight

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JTable singleLineRowHeight(JTable component)

      Updates `JTable.setRowHeight(int)` 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
      Returns:
        input component (for fluent APIs)

    - #### error

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JLabel error(JLabel component)

      Configures the label to look like `warning`.
      Parameters:
        `component` - input label
      Returns:
        input label (for fluent APIs)

    - #### warning

          @API(since="5.3",
               status=EXPERIMENTAL)
          public static JLabel warning(JLabel component)

      Configures the label to look like `error`.
      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<T> 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.

      Type Parameters:
        `T` - type of the component
      Parameters:
        `component` - component to update
        `onUpdateUi` - action to run (immediately and when look and feel changes)
      Returns:
        input component (e.g. for fluent APIs)

    - #### updateUi

          public static void updateUi(JComponent c)

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.