Creating a basic application from JViews Diagrammer beans

An alternative to using the predefined IlvDiagrammerApplication class is to combine the JViews Diagrammer beans yourself. You can do this either using an Integrated Development Environment (IDE), or directly in your Java™ code.
To create a very simple JViews Diagrammer application containing one diagram component ( IlvDiagrammer instance) and a view toolbar (IlvDiagrammerViewBar instance):
  • Write the following code
    A basic application that extends JFrame
    /** 
     * This is a very simple application based on a diagram component, 
     *  
     * This application displays a diagram component in a frame.
     * A simple data file is loaded and displayed using a 
     * basic style sheet. A predefined toolbar is also used. 
     */ 
    public class BasicDiagrammerApplication extends JFrame
    {  
      // Create the main frame.  
      //  
      public BasicDiagrammerApplication()  
      {    
        // Set up the frame.    
        //    
        super("Basic Diagrammer Application");        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
        setLocation(100, 100);    
        setSize(400, 300);        
        // Create the IlvDiagrammer instance.    
        //    
        IlvDiagrammer diagrammer = new IlvDiagrammer();    
        // Allow selection.   
        //    
        diagrammer.setSelectMode(true);        
        // Add the IlvDiagrammer instance.   
        //    
        getContentPane().setLayout(new BorderLayout());     
        getContentPane().add(diagrammer, BorderLayout.CENTER);        
        // Add a predefined toolbar for controlling the view    
        //  north of the frame.    
        // 
         getContentPane().add(new IlvDiagrammerViewBar(), BorderLayout.NORTH);
        try {      
        // Load a project file.     
        //      
        diagrammer.setDataFile(new URL("file:data/basic.idpr"));    
        } catch (Exception e) {      
          e.printStackTrace();    
        }  
      }   
      /**   
       * The main method of the application.   
       */   
      public static void main(String[] args)  
      {    
        // Create an instance of the application, and    
        // show it.   
        //    
        new BasicDiagrammerApplication().setVisible(true);  
      }
    }