-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfoPanel.java
More file actions
32 lines (26 loc) · 989 Bytes
/
Copy pathInfoPanel.java
File metadata and controls
32 lines (26 loc) · 989 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
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
public class InfoPanel extends JPanel {
private static final long serialVersionUID = 1L;
private static final int TEXT_AREA_HEIGHT = 40;
private static final int CHARACTER_WIDTH = 39;
private static final int FONT_SIZE = 14;
JTextArea textArea = new JTextArea(TEXT_AREA_HEIGHT, CHARACTER_WIDTH);
JScrollPane scrollPane = new JScrollPane(textArea);
DefaultCaret caret = (DefaultCaret)textArea.getCaret();
InfoPanel () {
textArea.setEditable(false);
textArea.setFont(new Font("Times New Roman", Font.PLAIN, FONT_SIZE));
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
setLayout(new BorderLayout());
add(scrollPane, BorderLayout.CENTER);
return;
}
public void displayString (String text) {
textArea.setText(textArea.getText()+"\n"+text);
}
}