Java Reference
In-Depth Information
Display 18.8
A Text Area with Scroll Bars (part 2 of 3)
12 public class ScrollBarDemo extends JFrame
13
implements ActionListener
14 {
15
public static final int WIDTH = 600;
16
public static final int HEIGHT = 400;
17
public static final int LINES = 15;
18
public static final int CHAR_PER_LINE = 30;
19
private JTextArea memoDisplay;
20
private String memo1;
21
private String memo2;
22 public static void main(String[] args)
23 {
24 ScrollBarDemo gui = new ScrollBarDemo();
25 gui.setVisible( true );
26 }
27 public ScrollBarDemo()
28 {
29 super ("Scroll Bars Demo");
30 setSize(WIDTH, HEIGHT);
31 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
32 JPanel buttonPanel = new JPanel();
33 buttonPanel.setBackground(Color.LIGHT_GRAY);
34 buttonPanel.setLayout( new FlowLayout());
35 JButton memo1Button = new JButton("Save Memo 1");
36 memo1Button.addActionListener( this );
37 buttonPanel.add(memo1Button);
38 JButton memo2Button = new JButton("Save Memo 2");
39 memo2Button.addActionListener( this );
40 buttonPanel.add(memo2Button);
41 JButton clearButton = new JButton("Clear");
42 clearButton.addActionListener( this );
43 buttonPanel.add(clearButton);
44 JButton get1Button = new JButton("Get Memo 1");
45 get1Button.addActionListener( this );
46 buttonPanel.add(get1Button);
47 JButton get2Button = new JButton("Get Memo 2");
48 get2Button.addActionListener( this );
49 buttonPanel.add(get2Button);
50 add(buttonPanel, BorderLayout.SOUTH);
51 JPanel textPanel = new JPanel();
52 textPanel.setBackground(Color.BLUE);
(continued)
Search WWH ::




Custom Search