谢谢

解决方案 »

  1.   

    这是源代码!!!!  
                     myFrame.removeAll();
    this.al = al;
    this.setLayout(new FlowLayout(FlowLayout.LEFT));
    System.out.println("执行HandInput构造方法。。");


    root = createNodes();
    model = new DefaultTreeModel(root);
    tree = new JTree(model);

    // 给tree加监听器
    tree.addTreeSelectionListener(this);
    // 设置选择模式为单选
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setRootVisible(true);

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(tree);
    this.add(pane); JPanel buttomPanel = new JPanel();
    JButton save = new JButton("Save");
    save.addActionListener(this);
    JButton finish = new JButton("Finish");
    finish.addActionListener(this);
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(this);
    buttomPanel.add(save);
    buttomPanel.add(finish);
    buttomPanel.add(cancel);
    buttomPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); textFieldPanel = new JPanel();
    textFieldPanel.setLayout(new GridLayout(3,1));


    JLabel ll = new JLabel("信息录入");



    textFieldPanel.add(ll);



    myFrame.getContentPane().add("West",this);
    myFrame.getContentPane().add("Center",textFieldPanel);
    myFrame.getContentPane().add("South", buttomPanel);
    myFrame.getContentPane().setVisible(true);

    System.out.println(myFrame.getContentPane().getComponentCount());
    System.out.println("----------&&&  "+myFrame.getComponentCount());
    myFrame.validate(); SwingUtilities.updateComponentTreeUI(myFrame);

    myFrame.setVisible(true);
      

  2.   

    现在的问题就是REMOVEALL()之后 再加入组件就显示不了了
      

  3.   

    是不是要调用窗体的repaint方法
      

  4.   

    jframe好像没有 updateUI()方法
    请问应该是调用谁的updateUI()呀!!
    谢谢!!
      

  5.   

    removeAll()添加jpanel组件后,调用updateUI()
    可以的。
      

  6.   

    原来是调用jpanel的update()!!
    谢谢各位!!
      

  7.   

    你removeall应该是去把getContentsPanel().removeAll(),这样不需要update()也可以的