remove
public void remove(int index)Removes the component, specified by index, from this container. Parameters:
index - the index of the component to be removed.
Since:
JDK1.1 
See Also:
add(java.awt.Component)--------------------------------------------------------------------------------remove
public void remove(Component comp)Removes the specified component from this container. Parameters:
comp - the component to be removed
See Also:
add(java.awt.Component)--------------------------------------------------------------------------------removeAll
public void removeAll()Removes all the components from this container. See Also:
add(java.awt.Component), remove(int)

解决方案 »

  1.   

    if(cfgsysadmin == selectedNode)
         {if(temppanel != null)
          jpanel.removeAll();
          if(demo == null)
          demo = new CfgSysadmini();
          temppanel = demo.getDemoPanel();
          jpanel.add(demo.getDemoPanel(), BorderLayout.NORTH);
          this.validate();
         }
         else if(sqlsysadmin == selectedNode )
         {
          if(temppanel != null)
          jpanel.removeAll();
          if(demo == null)
          demo = new SqlSysadmin();
          temppanel = demo.getDemoPanel();
          jpanel.add(demo.getDemoPanel(), BorderLayout.CENTER);
          this.validate();
         }
    显示不出第二次加入的component