Java Reference
In-Depth Information
Display 18.8 A Text Area with Scroll Bars (part 1 of 3)
1
import javax.swing.JFrame;
2
import javax.swing.JTextArea;
3
import javax.swing.JPanel;
4
import javax.swing.JLabel;
5
import javax.swing.JButton;
6
import javax.swing.JScrollPane;
7
import java.awt.BorderLayout;
8
import java.awt.FlowLayout;
9
import java.awt.Color;
10
import java.awt.event.ActionListener;
11
import java.awt.event.ActionEvent;
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);
Search WWH ::




Custom Search