【发布时间】:2014-02-14 06:23:45
【问题描述】:
正如标题所说,我想扫描一个 textArea。是否可以同时扫描数字和字符串?
还有一件事,我用setBounds作为textArea的位置,但是不起作用。
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class TextArea {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JTextArea area = new JTextArea(4, 10);
public TextArea() {
area.setBounds(110, 250, 40, 40); //doesn't work
frame.add(panel);
panel.add(area);
frame.setTitle("Area");
frame.setVisible(true);
frame.setSize(900, 580);
frame.setLocationRelativeTo(null);
}
public static void main(String[] args) {
new TextArea();
}
}
【问题讨论】:
-
不要使用
setBounds依赖于你隐含使用的布局管理器(FlowLayout)。扫描是什么意思?