| 
 | org.openide.explorer 6.5.31 1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.openide.explorer.propertysheet.PropertyPanel
public class PropertyPanel
PropertyPanel is a generic GUI component for displaying and editing a JavaBeans™ property or any compatible getter/setter pair for which there is a property editor available, in accordance with the JavaBeans specification. It makes it possible to instantiate an appropriate GUI component for a property and provides the plumbing between user interation with the gui component and calls to the getter/setter pair to update the value.
The simplest way to use PropertyPanel is by driving it from an instance of
 PropertySupport.Reflection.  To do that, simply pass the name of the
 property and an object with a getter/setter pair matching that property to the
 PropertySupport.Reflection's constructor, and pass the resulting instance of
 PropertySupport.Reflection to the PropertyPanel constructor.
A more efficient approach is to implement Node.Property or pass an existing Node.Property object to the PropertyPanel's constructor or PropertyPanel.setProperty - thus bypassing the use of reflection to locate the getter and setter.
A note on uses of Node.Property and PropertyModel: PropertyPanel was originally designed to work with instances of PropertyModel, and has since been rewritten to be driven by instances of Node.Property. The main reason for this is simplification - there is considerable overlap between PropertyModel and Node.Property; particularly, DefaultPropertyModel and PropertySupport.Reflection effectively are two ways of doing exactly the same thing.
Use of PropertyModel is still supported, but discouraged except under special
 circumstances.  The one significant difference between Node.Property
 and PropertyModel is that PropertyModel permits listening for changes.
It is generally accepted that GUI components whose contents unexpectedly change
 due to events beyond their control does not tend to lead to quality, usable user
 interfaces.  However, there are cases where a UI will, for example, contain several
 components and modification to one should immediately be reflected in the other.
 For such a case, use of PropertyModel is still supported.  For other cases,
 it makes more sense to use BeanNode and for the designer of the UI
 to make a design choice as to how to handle (if at all) unexpected changes happening to
 properties it is displaying.  If all you need to do is display or edit a
 property, use one of the constructors that takes a Node.Property object or
 use setProperty.  PropertyModel will be deprecated at some point
 in the future, when a suitable replacement more consistent with
 Node.Property is created.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent | 
|---|
| JComponent.AccessibleJComponent | 
| Nested classes/interfaces inherited from class java.awt.Container | 
|---|
| Container.AccessibleAWTContainer | 
| Nested classes/interfaces inherited from class java.awt.Component | 
|---|
| Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy | 
| Field Summary | |
|---|---|
| static int | PREF_CUSTOM_EDITORConstant defining a preference for rendering the value. | 
| static int | PREF_INPUT_STATEConstant defining a preference for rendering the value. | 
| static int | PREF_READ_ONLYConstant defining a preference for rendering the value. | 
| static int | PREF_TABLEUIConstant defining a preference for a borderless UI suitable for use in a table | 
| static String | PROP_MODELName of the 'model' property. | 
| static String | PROP_PREFERENCESName of the 'preferences' property. | 
| static String | PROP_PROPERTY_EDITORDeprecated. - the property editor is re-fetched from the underlying property object as needed. It is up to the property object to cache or not cache the property editor. This property will no longer be fired. | 
| static String | PROP_STATEName of property 'state' that describes the state of the embeded PropertyEditor. | 
| Fields inherited from class javax.swing.JComponent | 
|---|
| accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW | 
| Fields inherited from class java.awt.Component | 
|---|
| BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
| ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
| PropertyPanel()Creates new PropertyPanel backed by a dummy property | |
| PropertyPanel(Node.Property p)Create a new property panel for displaying/editing the specified property | |
| PropertyPanel(Node.Property p,
              int preferences)Create a new property panel for the specified property with the specified preferences. | |
| PropertyPanel(Object bean,
              String propertyName,
              int preferences)Creates new PropertyPanel with DefaultPropertyModel | |
| PropertyPanel(PropertyModel model,
              int preferences)Creates a new PropertyPanel. | |
| Method Summary | |
|---|---|
|  void | addNotify()Overridden to install the inner component that will display the property | 
|  void | doLayout() | 
| protected  void | firePropertyChange(String nm,
                   Object old,
                   Object nue)Overridden to catch changes in those client properties that are relevant to PropertyPanel | 
|  AccessibleContext | getAccessibleContext() | 
|  Dimension | getMinimumSize() | 
|  PropertyModel | getModel()Get the property model associated with this property panel. | 
|  int | getPreferences()Returns the preferences set for this property panel. | 
|  Dimension | getPreferredSize() | 
|  Node.Property | getProperty()Fetch the property that this PropertyPanel displays. | 
|  PropertyEditor | getPropertyEditor()Deprecated. The property panel does not cache the property editor, and depending on its state, it may not consistently return the same property editor instance on repeated calls. The current implementation will do so for editable states, but there is no guarantee this will remain so in the future. | 
|  Object | getState()Getter for the state of the property editor. | 
|  boolean | isChangeImmediate()Getter for property changeImmediate. | 
|  boolean | isFocusable()Overridden to return false in cases that the preferences specify a read-only state | 
|  void | layout() | 
|  void | paint(Graphics g) | 
| protected  void | processFocusEvent(FocusEvent fe) | 
|  void | removeNotify()Overridden to dispose the component that actually displays the property and any state information associated with it | 
|  void | requestFocus()Overridden to do nothing in a read only state, since some custom property editors (File chooser) are capable of receiving focus even if they are disabled, effectively making focus disappear | 
|  void | setBackground(Color c) | 
|  void | setChangeImmediate(boolean changeImmediate)Setter for property changeImmediate. | 
|  void | setEnabled(boolean enabled)Sets whether or not this component is enabled. | 
|  void | setForeground(Color c) | 
|  void | setModel(PropertyModel model)Setter for property model. | 
|  void | setPreferences(int preferences)Setter for visual preferences in displaying of the value of the property. | 
|  void | setProperty(Node.Property p)Set or change the property this PropertyPanel will display | 
|  String | toString()Overridden to provide information from the embedded property renderer if not in custom editor mode | 
|  void | updateValue()If the editor is ExPropertyEditor it tries to change the getStateproperty toPropertyEnv.STATE_VALIDstate. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public static final int PREF_READ_ONLY
public static final int PREF_CUSTOM_EDITOR
public static final int PREF_INPUT_STATE
public static final int PREF_TABLEUI
public static final String PROP_PREFERENCES
public static final String PROP_MODEL
public static final String PROP_PROPERTY_EDITOR
public static final String PROP_STATE
PropertyEnv.getState(), 
Constant Field Values| Constructor Detail | 
|---|
public PropertyPanel()
public PropertyPanel(Object bean, String propertyName, int preferences)
preferences - the preferences that affect how this propertypanel
 will operatebean - The instance of beanpropertyName - The name of the property to be displayedpublic PropertyPanel(PropertyModel model, int preferences)
model - The model to displayPropertyModelpublic PropertyPanel(Node.Property p, int preferences)
p - preferences - public PropertyPanel(Node.Property p)
p - A Property object for this node to representNode.Property| Method Detail | 
|---|
public void setBackground(Color c)
setBackground in class JComponentpublic void setForeground(Color c)
setForeground in class JComponentpublic void doLayout()
public void layout()
public Dimension getMinimumSize()
getMinimumSize in class JComponentpublic Dimension getPreferredSize()
getPreferredSize in class JComponentprotected void firePropertyChange(String nm, Object old, Object nue)
firePropertyChange in class Componentpublic boolean isFocusable()
isFocusable in class Componentpublic void requestFocus()
requestFocus in class JComponentprotected void processFocusEvent(FocusEvent fe)
processFocusEvent in class Componentpublic void addNotify()
addNotify in class JComponentpublic void removeNotify()
removeNotify in class JComponentpublic int getPreferences()
public void setPreferences(int preferences)
preferences - PREF_XXXX constantspublic PropertyModel getModel()
Note:
 This method is primarily here for backward compatibility, and the single
 use case where it is truly desirable to have a GUI component which reflects
 changes made by some source other than itself.  If you have used one
 of the constructors which takes a Node.Property instance
 or the setProperty method, this method will return a
 PropertyModel instance generated for the underlying Node.Property object.
 In such a case, the PropertyModel instance thus obtained will not
 fire changes due to changes made by calling setValue
 on the Node.Property.  For details on why this is the case,
 see issue
 37779.
setModel,
 or a generated instance of PropertyModel which wraps the Node.Property
 which was set in the constructor or via setProperty.public void setModel(PropertyModel model)
model - New model.public final void setProperty(Node.Property p)
p - the Propertypublic final Node.Property getProperty()
public final Object getState()
setState method of the PropertyEnv
 environment.
 
PropertyEnv.STATE_VALID if the editor is not the ExPropertyEditor
    one or other constant from PropertyEnv.STATE_* that was assigned to PropertyEnvpublic void updateValue()
getState property to PropertyEnv.STATE_VALID
 state. This may be vetoed, in such case a warning is presented to the user
 and the getState will still return the original value
 (different from STATE_VALID).
 
 Also updates the value if
 org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor
 is used.
public PropertyEditor getPropertyEditor()
null if it is not possible
 to obtain a property editor.
 Note:  When not in custom editor mode, PropertyPanel does
 not cache the editor supplied by the property.  If the PropertyPanel
 was initialized from an instance of (deprecated) DefaultPropertyModel,
 a different instance of the property editor may be constructed and
 returned for each call.  Client code must take this into account.
 .  For cases of initialization via a Node.Property object,
 it is up to the supplied Property to cache or not cache the property
 editor returned from getPropertyEditor() as suits its
 needs.
nullpublic void setEnabled(boolean enabled)
setEnabled in class JComponentenabled - flag defining the action.public boolean isChangeImmediate()
public void setChangeImmediate(boolean changeImmediate)
changeImmediate - New value of property changeImmediate.public String toString()
public void paint(Graphics g)
paint in class JComponentpublic AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponent| 
 | org.openide.explorer 6.5.31 1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||