<<< Model-View-Controller Design     Index     SwingMain.java >>>

11. A2 Adding JPanel


  • JPanels are containers that are

    • automatically double buffered

    • repainted more quickly and smoothly.

  • It is recommended that a program

    1. creates a simple JPanel

    2. adds the panel to JFrame object

    3. adds all other components to the panel object.

  • For example,

    
        JPanel jpan = new JPanel();
        frame.getContentPane().add( jpan );
        JButton jbut = new JButton( "Hello" );
        jpan.add( jbut );
    
    
  • See next slide for a complete program.


<<< Model-View-Controller Design     Index     SwingMain.java >>>