JViews Diagrammer Bean による基本的なアプリケーションの作成

定義済み IlvDiagrammerApplication クラスを使用する代わりに、JViews Diagrammer Bean を適宜組み合わせて使用します。統合開発環境 (IDE) を使用して組み合わせることも、Java™ コードで直接組み合わせることもできます。
1 つのダイアグラム・コンポーネント (IlvDiagrammer インスタンス) と 1 つの表示ツールバー (IlvDiagrammerViewBar インスタンス) を含む、きわめて簡単な JViews Diagrammer アプリケーションを作成するには、以下の手順に従います。
  • 以下のコードを記述します。
    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);  
      }
    }