有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

eclipsejava:删除(组件);不会立即移除按钮

所以我用这个来移除JPanel中的按钮。但是,按钮不会立即移除,而是在最小化窗口后才会消失。有什么建议吗

   jBOption2.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){

                    jPanel.remove(jButton2);

共 (1) 个答案

  1. # 1 楼答案

    如果我错了,请纠正我,但我认为它的工作方式应该与本文中提到的相同: https://stackoverflow.com/questions/11438512/...

    jPanel.remove(jButton2);
    jPanel.revalidate();
    jPanel.repaint();
    

    我希望这符合你的问题;)