java swing removeall_java中JFrame中函数removeAll的用法 | 学步园
用baidu搜了半天搜不出來,用google一下就出來了~~~
下面用自己的代碼來解釋下removeAll()的用法
注意一定要在getContentPane()中用removeAll();
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main extends JFrame{
private static final long serialVersionUID = 1L;
public JButton JJ=new JButton("fdsafd");
Main(){
this.setVisible(true);
}
public void add(){
this.add(JJ);
this.pack();
}
public void delete(){
removeAll();
}
}
import java.awt.FlowLayout;
public class Case {
public static void main(String args[]){
Main a=new Main();
a.add();
a.setLayout(new FlowLayout()); //removeAll()不移除布局格式。
a.getContentPane().removeAll(); //注意一定要在getContentPane()中用removeAll();
a.add();
a.setBounds(10, 10, 200, 210);
}
}
總結
以上是生活随笔為你收集整理的java swing removeall_java中JFrame中函数removeAll的用法 | 学步园的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php bean,php框架Phpbea
- 下一篇: mysql如何保证高可用_mysql怎么