Incorporating a Toolbar in a Java-Client Dataview

Each Dataview in the BI Beans has a toolbar that you can use with the Dataview in a Java-client application.

Instantiating the toolbar

To use a toolbar with a Dataview, you instantiate the toolbar, passing the Dataview to the constructor. The following code shows how to use a graph toolbar with a graph.


JFrame frame = new JFrame("My Graph"); // add a layout manager Container contentPane = frame.getContentPane();contentPane.setLayout(new BorderLayout()); // add a graph Graph myGraph = new Graph(); contentPane.add("Center", myGraph); // add a graph toolbar, connecting the graph GraphToolBar toolbar = new GraphToolBar(myGraph); contentPane.add("North", toolbar);

Updating the toolbar when the view is modified

The tools in the toolbar show the current values of properties of the Dataview and of its components. When a property value changes through the toolbar, the toolbar can properly keep track of these values. However, if the Dataview is modified through a user-interface panel or through some other way, the toolbar is not automatically notified of the change. So that the toolbar can accurately reflect the current values of the properties of the selected component, you need to update the toolbar.

To update the toolbar, call its setDataView method, passing the Dataview that the toolbar affects, as shown in the following line of code.


toolbar.setDataView(myGraph);

This line of code belongs with the code that calls the apply method of a user-interface panel. It also belongs with any other code that sets the properties of the Dataview or of its components.