【发布时间】:2018-01-03 01:17:50
【问题描述】:
晚上好,我是 Java 的 GUI 新手。我有以下代码:
public class FrameENN extends JFrame {
JButton b1;
JTextArea t1;
JLabel l1;
String c;
eHandler handler = new eHandler();
public FrameENN(String s) {
super(s);
setLayout(new FlowLayout());
b1 = new JButton("Get Result");
t1 = new JTextArea(5, 25);
l1 = new JLabel("");
add(b1);
add(t1);
add(l1);
b1.addActionListener(handler);
}
public class eHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1) {
for (int i = 0; i < 3; i++) {
**System.out.println(i);**
}
}
}
}
}
按下按钮在 JTextArea 中获取此 System.out.println(i) 时我该怎么办?我尝试使用 t1.append 但它没有用。谢谢你。
【问题讨论】:
标签: java swing jtextarea system.out