org.jvnet.lafwidget
Interface LafWidget<T extends javax.swing.JComponent>

All Known Implementing Classes:
AutoScrollWidget, DesktopIconHoverPreviewWidget, EditContextMenuWidget, GhostFadeWidget, IconGlowWidget, LafWidgetAdapter, LockBorderWidget, MenuSearchWidget, PasswordStrengthCheckerWidget, ScrollPaneSelectorWidget, SelectAllOnFocusGainWidget, SelectOnEscapeWidget, TabHoverPreviewWidget, TabOverviewDialogWidget, TabPagerWidget, TreeDragAndDropWidget

public interface LafWidget<T extends javax.swing.JComponent>

Interface for LAF widgets (behavioural traits).

Author:
Kirill Grouchnikov

Field Summary
static java.lang.String ANIMATION_KIND
           Client property name for specifying the kind of animation on various components.
static java.lang.String AUTO_SCROLL
           Client property name for specifying that a scroll pane should have auto-scroll support invoked on middle-mouse button click.
static java.lang.String COMPONENT_PREVIEW_PAINTER
           Client property name for specifying the preview painter for a component.
static java.lang.String IGNORE_GLOBAL_LOCALE
           Client property name for specifying that the label lookup for custom widgets and sub-components installed by various UI delegates should ignore the global locale (as returned by Locale.getDefault() and use the component-specific locale (as returned by Component.getLocale() instead.
static java.lang.String NO_LOCK_ICON
           Client property name for specifying that the LockBorderWidget should not put a lock icon.
static java.lang.String PASSWORD_STRENGTH_CHECKER
           Client property name for specifying password strength checker for a password field.
static java.lang.String TABBED_PANE_PREVIEW_PAINTER
           Client property name for specifying the preview painter for tabbed pane.
static java.lang.String TEXT_EDIT_CONTEXT_MENU
           Client property name for specifying that the text component should have the edit context menu (with Cut / Copy / Paste / ...
static java.lang.String TEXT_FLIP_SELECT_ON_ESCAPE
           Client property name for specifying that the text component contents should flip selection on ESCAPE key press.
static java.lang.String TEXT_SELECT_ON_FOCUS
           Client property name for specifying that the text component contents should be selected on focus gain.
static java.lang.String TREE_AUTO_DND_SUPPORT
          Client property name for specifying that the tree component should have automatic drag and drop support.
 
Method Summary
 void installComponents()
          Installs components for the associated component.
 void installDefaults()
          Installs default settings for the associated component.
 void installListeners()
          Installs listeners for the associated component.
 void installUI()
          Installs UI on the associated component.
 boolean requiresCustomLafSupport()
          Returns indication whether this widget requires custom LAF support.
 void setComponent(T jcomp)
          Associates a component with this widget.
 void uninstallComponents()
          Uninstalls components for the associated component.
 void uninstallDefaults()
          Uninstalls default settings for the associated component.
 void uninstallListeners()
          Uninstalls listeners for the associated component.
 void uninstallUI()
          Uninstalls UI on the associated component.
 

Field Detail

NO_LOCK_ICON

static final java.lang.String NO_LOCK_ICON

Client property name for specifying that the LockBorderWidget should not put a lock icon. This property can be set either on a single component or globally on UIManager. The value in both cases should be either Boolean.TRUE or Boolean.FALSE.

Since:
3.2
See Also:
Constant Field Values

TABBED_PANE_PREVIEW_PAINTER

static final java.lang.String TABBED_PANE_PREVIEW_PAINTER

Client property name for specifying the preview painter for tabbed pane. This property can be set either on a single tabbed pane or globally on UIManager. The value in both cases should be an instance of TabPreviewPainter. Default implementation of this DefaultTabPreviewPainter. Tabbed panes that have associated preview painters (set either on tabbed pane itself or globally on UIManager, have two widgets installed:

Here is an example of tabbed pane with default tab preview painter installed:

  JTabbedPane jtp = new JTabbedPane();
  jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER,
    new DefaultTabPreviewPainter());

See Also:
Constant Field Values

COMPONENT_PREVIEW_PAINTER

static final java.lang.String COMPONENT_PREVIEW_PAINTER

Client property name for specifying the preview painter for a component. This property can be set either on a component or globally on UIManager. The value in both cases should be an instance of PreviewPainter. Default implementation is available in the DefaultPreviewPainter.

Here is an example of a scroll pane with default preview painter installed on the internal component:

JPanel myPanel = new JPanel();
myPanel.putClientProperty(LafWidget.PANE_PREVIEW_PAINTER,
  new DefaultPreviewPainter());
JScrollPane jsp = new JScrollPane(myPanel);

See Also:
Constant Field Values

ANIMATION_KIND

static final java.lang.String ANIMATION_KIND

Client property name for specifying the kind of animation on various components. The value should be one of LafConstants.AnimationKind enum. This property can be set either on component or globally on UIManager.

In order to compute the animation kind for some component, the component's hierarchy is traversed bottom up. The first component that has this property set, defines the animation kind. Finally, if neither component not its ancestors define this property, the global setting on UIManager is checked. If there is no global setting, the default LafConstants.AnimationKind#REGULAR is taken. Here is an example:

  JPanel panel = new JPanel();
  panel.putClientProperty(LafWidget.ANIMATION_KIND, AnimationKind.SLOW);
  JButton b1 = new JButton("button1");
  JButton b2 = new JButton("button2");
  b2.putClientProperty(LafWidget.ANIMATION_KIND, AnimationKind.FAST);

In the example above, b2 will have fast animation, and b1 will have slow animation ("inherited" from the parent panel).

See Also:
Constant Field Values

PASSWORD_STRENGTH_CHECKER

static final java.lang.String PASSWORD_STRENGTH_CHECKER

Client property name for specifying password strength checker for a password field. The value should be an instance of PasswordStrengthChecker, otherwise will be ignored. This property must be set on a specific JPasswordField. Here is an example:

  JPasswordField jpf = new JPasswordField("password", 10);
  jpf.putClientProperty(LafWidget.PASSWORD_STRENGTH_CHECKER,
    new PasswordStrengthChecker() {
      public PasswordStrength getStrength(char[] password) {
        if (password == null)
          return PasswordStrength.WEAK;
        int length = password.length;
        if (length < 3)
          return PasswordStrength.WEAK;
        if (length < 6)
          return PasswordStrength.MEDIUM;
        return PasswordStrength.STRONG;
    }

    public String getDescription(PasswordStrength strength) {
      if (strength == PasswordStrength.WEAK)
        return "<html>This password is <b>way</b> too weak</html>";
      if (strength == PasswordStrength.MEDIUM)
        return "<html>Come on, you can do<br> a little better than that</html>";
      if (strength == PasswordStrength.STRONG)
        return "OK";
      return null;
    }
  });

See Also:
Constant Field Values

TEXT_SELECT_ON_FOCUS

static final java.lang.String TEXT_SELECT_ON_FOCUS

Client property name for specifying that the text component contents should be selected on focus gain. This property can be set either on a single text component or globally on UIManager. The value in both cases should be either Boolean.TRUE or Boolean.FALSE.

Here is an example of globally set property (all text components that don't specify Boolean.FALSE as a client property will have the "select all on focus gain" behaviour):

  UIManager.put(LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE);

See Also:
Constant Field Values

TEXT_FLIP_SELECT_ON_ESCAPE

static final java.lang.String TEXT_FLIP_SELECT_ON_ESCAPE

Client property name for specifying that the text component contents should flip selection on ESCAPE key press. This property can be set either on a single text component or globally on UIManager. The value in both cases should be either Boolean.TRUE or Boolean.FALSE.

Here is an example of globally set property (all text components that don't specify Boolean.FALSE as a client property will have the "flip select on escape" behaviour):

  UIManager.put(LafWidget.TEXT_FLIP_SELECT_ON_ESCAPE, Boolean.TRUE);

See Also:
Constant Field Values

TEXT_EDIT_CONTEXT_MENU

static final java.lang.String TEXT_EDIT_CONTEXT_MENU

Client property name for specifying that the text component should have the edit context menu (with Cut / Copy / Paste / ... menu items). This property can be set either on a single text component or globally on UIManager. The value in both cases should be either Boolean.TRUE or Boolean.FALSE.

Here is an example of globally set property (all text components that don't specify Boolean.FALSE as a client property will have the the edit context menu):

  UIManager.put(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE);

See Also:
Constant Field Values

TREE_AUTO_DND_SUPPORT

static final java.lang.String TREE_AUTO_DND_SUPPORT
Client property name for specifying that the tree component should have automatic drag and drop support. This property can be set either on a single tree or globally on UIManager. The value in both cases should be either Boolean.TRUE or Boolean.FALSE.

Here is an example of globally set property (all trees that don't specify Boolean.FALSE as a client property will have the automatic drag and drop support):

  UIManager.put(LafWidget.TREE_AUTO_DND_SUPPORT, Boolean.TRUE);

See Also:
Constant Field Values

AUTO_SCROLL

static final java.lang.String AUTO_SCROLL

Client property name for specifying that a scroll pane should have auto-scroll support invoked on middle-mouse button click. This property can be installed on a single scroll pane or globally on UIManager, and the value should be either Boolean.TRUE or Boolean.FALSE.

Here is an example of a scroll bar that has auto-scroll installed.

JScrollPane scrollPane = ...
scrollPane.putClientProperty(LafWidget.AUTO_SCROLL, Boolean.TRUE);

Since:
version 3.4
See Also:
Constant Field Values

IGNORE_GLOBAL_LOCALE

static final java.lang.String IGNORE_GLOBAL_LOCALE

Client property name for specifying that the label lookup for custom widgets and sub-components installed by various UI delegates should ignore the global locale (as returned by Locale.getDefault() and use the component-specific locale (as returned by Component.getLocale() instead. This property can be installed only on a single component, and the value should be either Boolean.TRUE or Boolean.FALSE.

Here is an example of menu bar that will be localized according to its own locale

JMenuBar jmb = ...
jmb.putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, Boolean.TRUE);

Since:
version 3.1
See Also:
Constant Field Values
Method Detail

setComponent

void setComponent(T jcomp)
Associates a component with this widget.

Parameters:
jcomp - Component.

requiresCustomLafSupport

boolean requiresCustomLafSupport()
Returns indication whether this widget requires custom LAF support. Some widgets such as TabOverviewDialogWidget or TabHoverPreviewWidget require custom implementation based on the internals of the specific LAF. Relevant functions in the base LafWidgetSupport support throw UnsupportedOperationException.

Returns:
true if this widget requires custom LAF support, false otherwise.

installUI

void installUI()
Installs UI on the associated component.


installDefaults

void installDefaults()
Installs default settings for the associated component.


installListeners

void installListeners()
Installs listeners for the associated component.


installComponents

void installComponents()
Installs components for the associated component.


uninstallUI

void uninstallUI()
Uninstalls UI on the associated component.


uninstallDefaults

void uninstallDefaults()
Uninstalls default settings for the associated component.


uninstallListeners

void uninstallListeners()
Uninstalls listeners for the associated component.


uninstallComponents

void uninstallComponents()
Uninstalls components for the associated component.