Home Segments Top Top Previous Next

1088: Mainline

Having defined the TestButton class, you can use instances of that class to experiment with, for example, the border-layout manager. The following, for example, defines a test panel:

import java.awt.*; 
import javax.swing.*; 
public class TestPanel extends JPanel { 
 public TestPanel() { 
  setLayout(new BorderLayout()); 
  add("North", new TestButton("N")); 
  add("East", new TestButton("E")); 
  add("South", new TestButton("S")); 
  add("West", new TestButton("W")); 
  add("Center", new TestButton("C")); 
 } 
}