New Event Model · JCChart and JCChartComponent
Java Beans is a specification that calls for the design of reusable, pre-built Java software components. It is designed to be a fully platform-independent component model written for the Java programming language. It enables developers to write components that can be re-used in other applications, reducing the total time needed to write complete applications. JClass Chart components are Java Bean-compliant.
The three main characteristics of a Bean are:
Properties are the named set and get public attributes associated with a Bean that can be read/write, read-only or write-only. A Bean also allows its methods to be called from other components. Beans fire events to notify other components that an action has happened.
Under the new model, "properties" are the named method attributes of a class that can affect its appearance or its behavior. Properties that are readable have a "get" method which enables the developer to read a property's value, and those properties which are writable have a "set" method which enable a property's value to be changed.
For example, the JCAxis object in JClass Chart has a property called AnnotationMethod. This property is used to control how an axis is labelled. To set the property value, the setAnnotationMethod() method is used. To get the property value, the getAnnotationMethod() method is used.
The main advantage of following the Java Beans specification is that it makes it very easy for a Java Integrated Development Environment (IDE) to "discover" the set of properties belonging to an object. The developer can then manipulate the properties of the object easily through the graphical interface of the IDE when constructing a program.
There are four ways in which JClass Chart properties can be modified:
In JClass Chart, all four methods use the same property name. As a result, this manual describes the behavior of a particular property instead of the behavior of a particular method or HTML tag.
Most IDEs list a component's properties in a property sheet or dialog. Simply find the property you want to set in this list and edit its value. Again, consult the IDE documentation for complete details.
For more detailed information on which properties are available from within a component, consult the JClass Chart API Reference.
If enabled by the developer, end-users can manipulate property values at run-time. Clicking a mouse button (right button on Windows 95/NT, middle button on Unix, or the button that launches popup menus on your OS) launches the JClass Chart Customizer. The user can navigate through the tabbed dialogs and edit the properties displayed.
Note: Property pages only appear at run time if the AllowUserChanges property of JCChart is set to true.
![]() |
xaxis.getAnnotationMethod()To set the AnnotationMethod property in the same object:
xaxis.setAnnotationMethod(JCAxis.POINT_LABELS);
<PARAM>
tags and set the chart properties defined in
the file. (A pre-built applet called JCChartApplet.class is
provided with JClass Chart).
Even standalone Java applications can save the values of chart properties to an HTML file, which can serve as a useful debugging tool.
Using HTML to set properties has the following benefits:
Chart properties are coded in HTML as applet <PARAM>
tags. The NAME
element of the <PARAM>
tag
specifies the property name; the VALUE
element specifies the
property value to set.
The easiest way to create a set of HTML properties is to use the JClass Chart Customizer to edit the required properties and save the property values to an HTML file. You can then view the generated HTML file and edit the properties further. For more details on using the Customizer, see Using the Chart Customizer.
The following HTML file uses an HTML parameter to add data to a
JCChartApplet
. The resulting chart is displayed below.
<HTML> <HEAD><TITLE>plot1</TITLE></HEAD> <BODY> <CENTER><H2>plot1</H2></CENTER> <APPLET CODE=jclass/chart/JCChartApplet.class CODEBASE="../../.." HEIGHT=300 WIDTH=400> <PARAM NAME=data VALUE=" ARRAY 2 4 # X-values 1.0 2.0 3.0 4.0 # Y-values 150.0 175.0 160.0 170.0 # Y-values set 2 125.0 100.0 225.0 300.0 "> </APPLET> </BODY> </HTML>
![]() |
A full listing of the syntax of JClass Chart properties when used in HTML files can be found in Appendix E: HTML Property Reference. Many example HTML files are located in the jclass/chart/applet/ directory.
In the JDK 1.0.2, the behavior of Java programs was typically modified by subclassing and overriding event handling classes. Subclassing overrode the default behavior of a method. This approach was clumsy because it required the programmer to have a thorough understanding of base class methods and internals before writing any code.
Bean-compliant JClass programs (like JClass Chart) provide the means for an application to be notified when an event occurs through event listeners. It works like this: if a component is acted upon by the user or from within the program, a JCFooEvent is fired. The JCFooListener (which has been registered by calling addFooListener() on the component) receives the instance and enacts the action to be taken. The programmer uses the JCFooListener to define what action or actions should take place when it receives the JCFooEvent.
JCChartComponent exists because the current generation of Java IDEs do not support properties in contained objects. While current Java IDEs allow properties in contained objects to be modified, they cannot yet properly generate code for the property change. JCChartComponent works around this problem by exposing many JClass Chart properties in one object. While not all properties are provided, the most common properties are available.
Since JCChartComponent is a subclass of JCChart, it is possible to switch and use the contained properties in JCChart.