Swing布局问题,多个Jpanel切换

我们在学习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) {
        
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值