Property Inspector is essential part of modern IDE and application builder
tools becoming a common unit of professional user interface.
Such approach reduces significantly (if not completely) number of dialogs
in an application, making
application user interface modern and consistent.
From the development perspective usage of Property Inspector minimizes greatly
time of development and code size. All you need is to write the beans responsible
for application logic and possibly some custom editors.
Basic concepts
Property Inspector is a component designed for displaying and editing of properties of the bean.
"Classic" Property Inspector consists of 2 columns: first column displays property
names; second column displays property values.
Property Inspector exploring BarChart bean.
By type of its value properties are divided into three groups:
Simple properties - as a rule value type of simple property is String
or simple Java type: boolean, byte, char, short,
int, long, float or double.
In the picture above title, orientation and autoLayout
are examples of simple properties.
Array properties - value of such property is an array.
Simple or composite property is associated with each array item value.
In the picture above columns is array property,
and composite property is associated with each array item.
Composite properties. Value of composite property is another bean, characterized
by its own set of properties.
Hierarchy of the properties
Bean properties can form a hierarchy, represented in Property Inspector as a
tree. In the example above BarChart bean has array property columns. Array items
presented by composite properties consisting from 4 simple properties: label,
value, color and visible.
Property editors
Property editor is used to display and edit the value of the property. For each value
type a specialized editor is required.
BeanExplorer comes pre-equipped with editors for all simple Java types (boolean, byte, char, short,
int, long, float and double),
as well as for more frequently used types like String, Dimension,
Color and Font (see the picture above).
Embedding Property Inspector into your application
Property Inspector itself is a bean that can be easily embedded in any Java application.
The example below demonstrates sample application (see the complete
code given below). The left pane contains a bean (BarChart), the right pane contains Property
Inspector that manipulates properties of the bean.
In simple scenarios to embed Property Inspector into your application you need only four lines of code:
Specify a class to import
import com.beanexplorer.swing.PropertyInspector;
Create instance of Property Inspector
PropertyInspector propertyInspector = new PropertyInspector();
Set up the bean to be explored in Property Inspector
propertyInspector.explore(bean);
Insert PropertyInspector into application frame or panel
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
bean, propertyInspector);
To compile and run the application add beanhelpers.jar and beanexplorer.jar
into application classpath