【发布时间】:2013-09-18 14:03:06
【问题描述】:
我正在尝试在同一位置使用面板上的按钮取消隐藏文本区域。
代码如下:
public class experiment {
public static void main(String[] args){
final JFrame f = new JFrame("experiment");
final JTextArea tx = new JTextArea();
final JPanel pn = new JPanel();
final JButton bt = new JButton("click me");
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(tx);
tx.setText("hello");
f.add(pn);
pn.add(bt);
bt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
pn.remove(bt);
f.remove(pn);
}
});
}}
但它没有向我显示其中包含文本的文本区域..
请帮忙。 谢谢
【问题讨论】:
-
如果您认为它没有用......或者简单,那么为什么您没有重播答案。仍然没有给出所需的输出......
标签: java swing jpanel jtextarea