且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从JPanel动态删除Component

更新时间:2023-12-05 07:59:22

使用方法 Container.remove(Component),你可以从容器中删除任何组件。例如:

Using the method Container.remove(Component), you can remove any component from the container. For example:

JPanel j = new JPanel();

JButton btn1 = new JButton();

JButton btn2 = new JButton();

j.add(btn1);

j.add(btn2);

j.remove(btn1);