- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuiTextArea.java
More file actions
Latest commit
executable file
·36 lines (27 loc) · 862 Bytes
/
Copy pathGuiTextArea.java
File metadata and controls
executable file
·36 lines (27 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
importjavax.swing.*;
publicclassGuiTextArea {
JTextAreamyArea;
//--------------------
GuiTextArea(Stringtitle) {
//Create and set up the window
JFrameframe = newJFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myArea = newJTextArea(20, 40);
myArea.setEditable(false);
JScrollPanescrollPane =
newJScrollPane(myArea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.getContentPane().add(scrollPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
//--------------------
publicvoidprint(Strings) {
myArea.append(s);
myArea.setCaretPosition(myArea.getDocument().getLength());
}
publicvoidprintln(Strings) { print(s+"\n"); }
publicvoidprintln() { print("\n"); }
}