Property Inspector

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:

  1. Specify a class to import
    import com.beanexplorer.swing.PropertyInspector;
  2. Create instance of Property Inspector
    PropertyInspector propertyInspector = new PropertyInspector();
  3. Set up the bean to be explored in Property Inspector
  4. Insert PropertyInspector into application frame or panel
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 
                                          bean, propertyInspector);
  5. To compile and run the application add beanhelpers.jar and beanexplorer.jar into application classpath
    java -classpath .;beanhelpers.jar;beanexplorer.jar SampleApplication

Sample application code

import com.beanexplorer.swing.PropertyInspector;

import barchart.*;

import java.awt.*
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

public class SampleApplication extends JFrame
    public SampleApplication()
        super("Bean Explorer Sample Application");

        // initialise the bean
        Column[] columns = {new Column("Q1", 5,  Color.blue),
                            new Column("Q2", 8,  Color.red),
                            new Column("Q3", 10, Color.magenta),
                            new Column("Q4", 7,  Color.pink)};
        BarChart bean = new BarChart("Quarter report", columns);

        // initialize property inspector
        PropertyInspector propertyInspector = new PropertyInspector();

        // explore the bean

        // insert bean and PropertyInspector into application frame
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                              bean, propertyInspector);
        getContentPane().add(splitPane, BorderLayout.CENTER);

    static public void main(String[] args)
        SimpleApplication app = new SimpleApplication();
        app.setSize(new Dimension(400, 300));

 Do you know...
You can order development of a JavaTM application based on BeanExplorerTM.
It is much cheaper than to develop applications inside the US or Europe.
Visit our Services page for details.

::home:: ::about us:: ::news:: ::products:: ::services:: ::employment:: ::site map:: ::contact us::

Copyright © 2000-2006 DevelopmentOnTheEdge.com. All rights reserved.
Design by
Last modified: Thursday, 26-Jan-2012 14:25:17 +07