回复2://一个按钮
private void jButton1_actionPerformed(ActionEvent e) {
getSelectManage();
}
//构造函数(调用的不是一个JFrame,而是一个JPane)
private void getSelectManage(){
if(selectManage==null){
selectManage=new SelectManage();
selectManage.setTable();//同步获得表数据
}else{
}
this.getContentPane().remove(this.panelCenter);
panelCenter = selectManage;
this.getContentPane().add(selectManage,BorderLayout.CENTER);
this.repaint();
this.statusBar.setText("信息查询--档案");
}
好像有点类似中介者的意思,上面的代码就可以,拿去改一下就好了。
回复3:直接把JFRAME的布局管理器设置成卡片布局Cardlayout
然后调用它的first(),last(),next(),show()等方法就能实现JPanel切换了
回复4:可以用卡片布局不
回复5:现在回答晚吗?
回复6:假设JFrame的对象是jFrame,jFrame里面有一个JPanel对象jPanel1:(jFrame.add(jPanel1,"Center");),现在想反jPanel1换成jPanel2.
1,先想办法获取jFrame对象。
2,重新加一遍组件:(jFrame.add(jPanel2,"Center");)
3,再调用一遍setVisible方法。(jFrame.setVisible(true);)
回复7:漏了一点,在第一步和第二步之间加上:
1.5,删除原组件:(jFrame.remove(jPanel1);)