Home Segments Top Top Previous Next

965: Mainline

To produce the display in Segment 964, you remove the default layout manager via the call to setLayout with a null argument. Then, the components are positioned and sized, in squares, with setBounds expressions. The positions and sizes are fixed; they do not change as the you change the size of their surrounding container.

import javax.swing.*; 
import java.awt.event.*; 
import java.util.*; 
public class MovieApplicationSansLayout extends MovieApplication { 
 public MovieApplicationSansLayout () { 
  super(); 
  JScrollPane scroller = new JScrollPane(getJList()); 
  getContentPane().setLayout(null); 
  getContentPane().add("Meter", getMeter());                     
  getContentPane().add("List", scroller);  
  getContentPane().add("Form", getForm());               
  getContentPane().add("Poster", getPoster());                                   
  getMeter().setBounds(0, 0, 200, 200); 
  getPoster().setBounds(200, 0, 200, 200); 
  scroller.setBounds(0, 200, 200, 200); 
  getForm().setBounds(200, 200, 200, 200); 
 } 
}