开发者

Remove JPanel with some JComponents from JDialog

开发者 https://www.devze.com 2023-03-10 15:14 出处:网络
if c开发者_如何学运维reated a JPanel and then added some JComponents with these rules public class MyPanel extends JPanel {

if c开发者_如何学运维reated a JPanel and then added some JComponents with these rules

public class MyPanel extends JPanel {
    myButton = new MyButton()
    myButton.addXxxListener(...)
    myButton ....
    add(myButton)
}

public class MyButton extends JButton {
    //some constructors for parametrize JButton Object
    //build only JButton Object value or listener(s) are added in parent 
}
//and on runtime are all values added by using constructor or getter/setter 

then if I want to remove correctly this JPanel(s) from JDialog (remove all referencies and dispose that to the GC) I must

1/ at 1st. have to remove JComponents from JPanel, thenafter JPanel from JDialog

2/ just directly remove JPanel from JDialog


just removing the panel and all listeners should suffice, as long you don't reference any of its subcomponents from other objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消