■ swingコンポーネント->JTextArea |
||||
テキストが複数行入力可能な領域です。表示や編集することができます。 | ||||
|
||||
|
||||
コンストラクタ(抜粋) | ||||
|
||||
メソッド(抜粋) | ||||
|
||||
|
||||
JTextAreaSample.java | ||||
import java.awt.*; | ||||
import java.awt.event.*; | ||||
import javax.swing.*; | ||||
public class JTextAreaSample extends JFrame { | ||||
Container contentPane; | ||||
JTextArea txtArea = new JTextArea("文字を入力できます。"); | ← @インスタンス生成 | |||
public JTextAreaSample() { | ||||
super(JTextAreaSample); | ||||
addWindowAdapter(new WindowListener() { | ||||
public void windowClosing(WindowEvent e) { | ||||
System.exit(0); | ||||
} | ||||
}); | ||||
contentPane = getContentPane(); | ||||
contentPane.setLayout(new BorderLayout()); | ||||
contentPane.add(BorderLayout.CENTER,txtArea); | ||||
setSize(300,200); | ||||
setVisible(true); | ||||
} | ||||
} | ||||
public static void main(String[] args) { | ||||
JTextAreaSample myClass = new JTextAreaSample(); | ||||
} | ||||
} | ||||
@JTextAreaのインスタンスを生成 インスタンスを生成しています。 |
||||
※マウスの範囲選択や、ctrl+cでのコピー、ctrl+vでの貼り付けはできます。 | ||||
もどる |