⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.java~61~

📁 JAVA版ATM会员机模拟程序设计
💻 JAVA~61~
字号:
package com.zhou.view;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Toolkit;
import javax.swing.*;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.*;
import javax.swing.ImageIcon;
/**
 * <p>Title: ATM模拟系统</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: 第三小组</p>
 *
 * @author 第三小组
 * @version 1.0
 */

public class MainFrame extends JFrame {
    JPanel contentPane;
    JLabel jLabel1 = new JLabel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel2 = new JLabel();
    BackgroundImage jPanel1 = new BackgroundImage();

    public MainFrame() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();

        contentPane.setLayout(null);
        jPanel1.setImage("Image//b1.jpg");
        setSize(new Dimension(800, 600));
        setTitle("ATM模拟系统");
        jLabel1.setFont(new java.awt.Font("黑体", Font.PLAIN, 29));
        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setText("欢  迎  使  用");
        jLabel1.setBounds(new Rectangle(209, 55, 250, 50));
        jButton1.setBounds(new Rectangle(74, 339, 105, 40));
        jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        //jButton1.setText("登  录");

        jButton1.setIcon(new ImageIcon("Image//denglu.jpg"));
        jButton1.addActionListener(new MainFrame_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(247, 341, 120, 40));
        jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        //jButton2.setText("开  户");
        jButton2.setIcon(new ImageIcon("Image//tuichu.jpg"));
        jButton2.addActionListener(new MainFrame_jButton2_actionAdapter(this));
        jButton3.setBounds(new Rectangle(421, 340, 120, 40));
        jButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jButton3.setText("退  出");
        jButton3.addActionListener(new MainFrame_jButton3_actionAdapter(this));
        jLabel3.setFont(new java.awt.Font("黑体", Font.PLAIN, 28));
        jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel3.setText("ATM  取  款  模  拟  机");
        jLabel3.setBounds(new Rectangle(172, 194, 322, 32));
        jPanel1.setLayout(null);
        jPanel1.setBounds(new Rectangle(0, 0, 800, 600));
        jPanel1.add(jButton2);
        jPanel1.add(jButton3);
        jPanel1.add(jLabel3);
        jPanel1.add(jButton1);
        jPanel1.add(jLabel1);
        contentPane.add(jPanel1, null);
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        DengLuFrame denglu = new DengLuFrame();
        denglu.setSize(800, 600);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = denglu.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        denglu.setLocation((screenSize.width - frameSize.width) / 2,
                           (screenSize.height - frameSize.height) / 2);
        denglu.setVisible(true);
        this.dispose();
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        ZhuCeFrame zhuce = new ZhuCeFrame();
        zhuce.setSize(800, 600);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = zhuce.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        zhuce.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);

        zhuce.setVisible(true);

        this.dispose();

    }

    public void jButton3_actionPerformed(ActionEvent e) {
        this.dispose();
    }
}


class MainFrame_jButton3_actionAdapter implements ActionListener {
    private MainFrame adaptee;
    MainFrame_jButton3_actionAdapter(MainFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class MainFrame_jButton2_actionAdapter implements ActionListener {
    private MainFrame adaptee;
    MainFrame_jButton2_actionAdapter(MainFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class MainFrame_jButton1_actionAdapter implements ActionListener {
    private MainFrame adaptee;
    MainFrame_jButton1_actionAdapter(MainFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -