我们在学习swing的时候,可能总会有这样一种需求,从一个面板到另一个面板,甚至到另一个面板,然后再从另一面板回到这个面板,说白了就是界面切换吧!下面说一下我的小demo,希望给大家带一个领头作用。个人编写,转载注明出处。
package com.dzy.swing;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class MainFrame extends JFrame implements ActionListener {
private MainFrame mainFrame;
private FirstPanel firstPanel;
private JButton go;
//下面定义为了切换面板方便
private SecondPanel secondPanel;
private ThirdPanel thirdPanel;
public void setSecondPanel(SecondPanel secondPanel) {
this.secondPanel = secondPanel;
}
public SecondPanel getSecondPanel() {
return secondPanel;
}
public FirstPanel getFirstPanel() {
return firstPanel;
}
public void setFirstPanel(FirstPanel firstPanel) {
this.firstPanel = firstPanel;
}
public ThirdPanel getThirdPanel() {
return thirdPanel;
}
public void setThirdPanel(ThirdPanel thirdPanel) {