skip to main content
Defense > Programmer's documentation > Essential Features > Getting started with JViews Framework > Stage 1 - The manager
 
Stage 1 - The manager
Overview of stage 1
The manager organizes sets of graphic objects into multiple views and layers and provides the possibility of higher-level interactions. These features are brought out as the tutorial progresses. When running the Sample1 example, the first stage in this tutorial, you see a scrolling window displaying the picture of a person.
Explanations of the Sample1.java file follow.
Sample1
Importing the library and packages
The Sample1.java file first imports the main Rogue Wave® JViews package and then imports the Rogue Wave JViews Swing package for the GUI components.
 
import ilog.views.*;
import ilog.views.swing.*;
To use AWT and Swing classes, the sample must import the swing and awt packages:
 
import javax.swing.*;
import java.awt.*;
Creating the frame class
After importing packages, you can create the class named Sample1. This class has two fields, manager (class IlvManager) to store the graphic objects, and mgrview, (class IlvManagerView), to display the contents of the manager.
 
public class Sample1 extends JFrame
{
  IlvManager manager;
  IlvManagerView mgrview;
  ....
}
Creating the manager
Use the constructor to create the manager:
 
...
  manager = new IlvManager();
   ...
}
Loading/reading a file
Once the manager is created, you can read the lou.ivl file which can be found in the data directory. Rogue Wave JViews Framework provides facilities to save and read graphic objects in a manager. These files are in the IVL format.
You need to catch the exception that may occur when reading the file. The method read of the class IlvManager may throw the following exceptions:
*IOException for basic IO errors.
*IlvReadFileException, if the format of the file is not correct (the file is not an .ivl formatted file) or if a graphic class needed to load the file cannot be found.
 
try {
  manager.read("data/lou.ivl");
} catch (Exception e) {}
Creating the view
Next create a manager view to display the contents of the manager. A manager view is an instance of the IlvManagerView class. To associate it with the manager, all you have to do is provide the manager parameter as shown below.
NOTE  This example uses the class IlvJScrollManagerView. This class encapsulates the class IlvManagerView and provides scroll bars.
 
mgrview = new IlvManagerView(manager);
getContentPane().setLayout(new BorderLayout(0,0));
getContentPane().add(new IlvJScrollManagerView(mgrview), BorderLayout.CENTER);
Testing the application
To test the application, you need the jviews-framework-all.jar file in your classpath. On a Windows® machine this will be:
 
set CLASSPATH=.;<installdir>/jviews-framework/lib/jviews-framework-
all.jar

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.