All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jvnet.lafwidget.LafWidget Maven / Gradle / Ivy

Go to download

Laf-Widget provides support for common "feel" widgets in look-and-feel libraries

There is a newer version: 5.0
Show newest version
/*
 * Copyright (c) 2005-2006 Laf-Widget Kirill Grouchnikov. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 * 
 *  o Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer. 
 *     
 *  o Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution. 
 *     
 *  o Neither the name of Laf-Widget Kirill Grouchnikov nor the names of 
 *    its contributors may be used to endorse or promote products derived 
 *    from this software without specific prior written permission. 
 *     
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
package org.jvnet.lafwidget;

import javax.swing.*;

import org.jvnet.lafwidget.tabbed.*;
import org.jvnet.lafwidget.text.PasswordStrengthChecker;
import org.jvnet.lafwidget.utils.LafConstants;

/**
 * Interface for LAF widgets (behavioural traits).
 * 
 * @author Kirill Grouchnikov
 */
public interface LafWidget {
	/**
	 * Client property name for specifying that the editable combobox can accept
	 * only entries from the model. This property can be set either on a single
	 * combobox or globally on {@link UIManager}. The value in both cases
	 * should be either {@link Boolean#TRUE} or {@link Boolean#FALSE}.
*
* * Here is an example of editable combobox that accepts model-entries only:
*
* *   final JComboBox comboCompletionModelOnlyTest = new JComboBox(
*     new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" });
*   comboCompletionModelOnlyTest.setEditable(true);
*   comboCompletionModelOnlyTest.putClientProperty(
*     LafWidget.COMBO_BOX_USE_MODEL_ONLY, Boolean.TRUE); *
*/ public final static String COMBO_BOX_USE_MODEL_ONLY = "lafwidgets.comboboxUseModelOnly"; /** * 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 * {@link UIManager}. The value in both cases should be an instance of * {@link TabPreviewPainter}. Default implementation of this * {@link DefaultTabPreviewPainter}. Tabbed panes that have associated * preview painters (set either on tabbed pane itself or globally on * {@link UIManager}, have two widgets installed: *
    *
  • Tab overview dialog from {@link TabOverviewDialogWidget} *
  • Tab hover preview from {@link TabHoverPreviewWidget} *
* * 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()); *
*/ public final static String TABBED_PANE_PREVIEW_PAINTER = "lafwidgets.tabbedpanePreviewPainter"; /** * Client property name for specifying the kind of animation on various * components. The value should be one of {@link LafConstants.AnimationKind} * enum. This property can be set either on component or globally on * {@link 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 * {@link UIManager} is checked. If there is no global setting, the default * {@link 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). */ public final static String ANIMATION_KIND = "lafwidgets.animationKind"; /** * Client property name for specifying password strength checker for a * password field. The value should be an instance of * {@link PasswordStrengthChecker}, otherwise will be ignored. This * property must be set on a specific {@link 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;
*     }
*   }); *
*/ public final static String PASSWORD_STRENGTH_CHECKER = "lafwidgets.passwordStrengthChecker"; /** * 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 {@link UIManager}. The value in * both cases should be either {@link Boolean#TRUE} or {@link Boolean#FALSE}.
*
* Here is an example of globally set property (all text components that * don't specify {@link Boolean#FALSE} as a client property will have the * "select all on focus gain" behaviour):
*
* *   UIManager.put(LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE); * */ public final static String TEXT_SELECT_ON_FOCUS = "lafwidgets.textSelectAllOnFocus"; /** * 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 * {@link UIManager}. The value in both cases should be either * {@link Boolean#TRUE} or {@link Boolean#FALSE}.
*
* Here is an example of globally set property (all text components that * don't specify {@link Boolean#FALSE} as a client property will have the * the edit context menu):
*
* *   UIManager.put(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE); * */ public final static String TEXT_EDIT_CONTEXT_MENU = "lafwidgets.textEditContextMenu"; /** * 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 text component or globally on {@link UIManager}. The value in * both cases should be either {@link Boolean#TRUE} or {@link Boolean#FALSE}.
*
* Here is an example of globally set property (all trees that don't specify * {@link Boolean#FALSE} as a client property will have the automatic drag * and drop support):
*
* *   UIManager.put(LafWidget.TREE_AUTO_DND_SUPPORT, Boolean.TRUE); * */ public final static String TREE_AUTO_DND_SUPPORT = "lafwidgets.treeAutoDnDSupport"; /** * Associates a component with this widget. * * @param jcomp * Component. */ public void setComponent(JComponent jcomp); /** * Returns indication whether this widget requires custom LAF * support. Some widgets such as {@link TabOverviewDialogWidget} or * {@link TabHoverPreviewWidget} require custom implementation based on the * internals of the specific LAF. Relevant functions in the base * {@link LafWidgetSupport} support throw * {@link UnsupportedOperationException}. * * @return true if this widget requires custom * LAF support, false otherwise. */ public boolean requiresCustomLafSupport(); /** * Installs UI on the associated component. */ public void installUI(); /** * Installs default settings for the associated component. */ public void installDefaults(); /** * Installs listeners for the associated component. */ public void installListeners(); /** * Installs components for the associated component. */ public void installComponents(); /** * Uninstalls UI on the associated component. */ public void uninstallUI(); /** * Uninstalls default settings for the associated component. */ public void uninstallDefaults(); /** * Uninstalls listeners for the associated component. */ public void uninstallListeners(); /** * Uninstalls components for the associated component. */ public void uninstallComponents(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy