1: //..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
2: /*
3: * Copyright (c) 2010-2011, KOTSUBU-chan and/or its affiliates.
4: * All rights reserved.
5: * @version 1.0
6: */
7: package cherry;
8:
9: import java.awt.*;
10: import javax.swing.*;
11:
12: // ----------------------------------------
13: public class ExTextArea extends JFrame {
14: private JTextArea textArea;
15:
16: // ----------------------------------------
17: public ExTextArea(String title, Dimension d) {
18: this.init();
19: this.initFrame(title, d);
20: }
21:
22: private void init() {
23: this.textArea = new JTextArea();
24: this.textArea.setText("-- JTextArea --\n");
25: for (char e: "ABCD".toCharArray()) {
26: this.textArea.append(
27: String.format("Line: %c\n", e));
28: }
29: }
30:
31: private void initFrame(String title, Dimension d) {
32: this.setLocationRelativeTo(null);
33: this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
34:
35: this.setTitle(title);
36: this.setSize(d);
37:
38: JPanel panel = new JPanel();
39: panel.setLayout(new BorderLayout());
40: this.getContentPane().add(panel);
41:
42: JScrollPane scrollPane = new JScrollPane();
43: scrollPane.getViewport().add(this.textArea);
44: panel.add(scrollPane, BorderLayout.CENTER);
45: }
46:
47: // ----------------------------------------
48: static void tips() {
49: ExTextArea ex = new ExTextArea(
50: "Ex: JTextArea",
51: new Dimension(200, 120));
52: ex.setVisible(true);
53: }
54:
55: // ----------------------------------------
56: ExTextArea() {}
57: static String version = new ExTextArea()
58: .getClass().getName()+": #1.0.05";
59: }
60:
61: // ========================================