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

📄 restaurant.java

📁 java版虚拟社区,在mysql上运行.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package clientpack;
import javax.swing.ListSelectionModel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.Dimension;
import java.io.PrintStream;
import java.util.Scanner;
import java.awt.Toolkit;

import javax.swing.JPasswordField;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.util.Vector;
public class Restaurant extends JFrame {

    private static final long serialVersionUID = 1L;

    private String id;
    private MyMessage mm;
    private Message mes;
    private boolean iflog;

    private int RowNumBank;


	private JButton bankrecord_jButton = null;

	private JPanel bankrecord_jPanel = null;

	private JScrollPane bankrecord_jScrollPane = null;

	private JTable bankrecord_jTable = null;

	private JButton payback_jButton = null;

	private JButton loanview_jButton = null;

    private JPanel jContentPane = null;

    private JButton personalbank = null;

    private JPanel bankPanel = null;

    private JPanel softwarePanel = null;

    private JPanel restaurantPanel = null;

    private JButton checkaccount = null;

    private JButton deposit = null;

    private JButton withdraw = null;

    private JButton transfer = null;

    private JButton loan = null;

    private JPanel bankenterPanel = null;

    private JPasswordField jPasswordField = null;

    private JLabel jLabel = null;

    private JButton enter = null;

    private JLabel jLabel1 = null;

    private JButton newaccount = null;

    private JPanel regaccountPanel = null;

    private JPasswordField regpassword = null;

    private JPasswordField regpasswordconfirm = null;

    private JTextField regaccount = null;

    private JTextField regcash = null;

    private JLabel jLabel2 = null;

    private JLabel jLabel3 = null;

    private JLabel jLabel4 = null;

    private JLabel jLabel5 = null;

    private JButton regok = null;

    private JButton regback = null;

    private JTextField bankpanel_jTextField = null;

    private JTextField bankpanel_jTextField2 = null;

    private JLabel jLabel6 = null;

    private JLabel jLabel7 = null;

    private JLabel jLabel8 = null;

    private JButton bankpanel_deposit = null;

    private JButton bankpanel_withdraw = null;

    private JButton bankpanel_transfer = null;

    private JButton bankpanel_loan = null;

    private JLabel note_jLabel = null;
    private JButton AddtoMenuButton = new JButton();
    private JPanel AddMenuPanel = new JPanel();
    private JLabel FoodNameLabel = new JLabel();
    private JTextField FoodNameTextField = new JTextField();
    private JLabel PriceLabel = new JLabel();
    private JTextField PriceTextField = new JTextField();
    private JButton OKButton = new JButton();
    private JButton CancelButton = new JButton();
    private JButton MenuViewButton = new JButton();
    private JScrollPane MenuViewPanel = new JScrollPane();
    private String[] MenuViewColumnname = {"菜名","价格"};
    private String[] CustomerViewColumnname = {"id","姓名","点菜清单","价格","时间"};
    private DefaultTableModel MenuViewdatamode = new DefaultTableModel(null,MenuViewColumnname)
                        {
                            public boolean isCellEditable(int row, int column) {
                                return false;
                            }

                        };
    private DefaultTableModel CustomerViewdatamode = new DefaultTableModel(null,CustomerViewColumnname) {
        public boolean isCellEditable(int row, int column) {
            return false;
        }

    };

    private JTable MenuViewTable = new JTable(MenuViewdatamode);
    private JButton CustomerViewButton = new JButton();
    private JScrollPane CustomerViewPanel = new JScrollPane();
    private JTable CustomerViewTable = new JTable(CustomerViewdatamode);
    private JButton FinanceButton = new JButton();
    private JPanel FinancePanel = new JPanel();
    private JLabel FinanceLabel = new JLabel();
    private JTextField FinanceTextField = new JTextField();
    /**
         * This is the default constructor
         */
        public Restaurant(Scanner pin, PrintStream pout,String sid) {
                super();
                initialize();
                id = sid;
                mes = new Message(pin,pout);
                mm = new MyMessage();
                iflog = false;
                setCenter();

        }

        /**
         * This method initializes this
         *
         * @return void
         */
        private void initialize() {
            this.setSize(722, 520);
            this.setContentPane(getJContentPane());
            this.setTitle("Restaurant");
            this.setVisible(true);
            AddtoMenuButton.setBounds(new Rectangle(147, 21, 98, 28));
            AddtoMenuButton.setText("添加新菜");
            AddtoMenuButton.addActionListener(new
                                              Restaurant_AddtoMenuButton_actionAdapter(this));
            AddMenuPanel.setBounds(new Rectangle(5, 91, 695, 381));
            AddMenuPanel.setLayout(null);
            FoodNameLabel.setText("Foodname:");
            FoodNameLabel.setBounds(new Rectangle(250, 80, 65, 33));
            FoodNameTextField.setText("");
            FoodNameTextField.setBounds(new Rectangle(307, 85, 127, 22));
            PriceLabel.setText("Price:");
            PriceLabel.setBounds(new Rectangle(267, 114, 47, 33));
            PriceTextField.setBounds(new Rectangle(307, 122, 127, 22));
            OKButton.setBounds(new Rectangle(280, 161, 80, 22));
            OKButton.setText("OK");
	        OKButton.addActionListener(new Restaurant_OKButton_actionAdapter(this));
	        CancelButton.setBounds(new Rectangle(375, 161, 80, 22));
            CancelButton.setText("Cancel");
            CancelButton.addActionListener(new
                                           Restaurant_CancelButton_actionAdapter(this));
            MenuViewButton.setBounds(new Rectangle(247, 21, 98, 28));
            MenuViewButton.setText("菜单查看");
            MenuViewButton.addActionListener(new
                                             Restaurant_MenuViewButton_actionAdapter(this));
            MenuViewPanel.setBounds(new Rectangle(5, 91, 695, 381));
            CustomerViewButton.setBounds(new Rectangle(347, 21, 98, 28));
            CustomerViewButton.setText("顾客清单");
            CustomerViewButton.addActionListener(new
                                                 Restaurant_CustomerViewButton_actionAdapter(this));
            CustomerViewPanel.setBounds(new Rectangle(5, 91, 695, 381));
            FinanceButton.setBounds(new Rectangle(447, 21, 98, 28));
            FinanceButton.setText("账目统计");
            FinanceButton.addActionListener(new
                                            Restaurant_FinanceButton_actionAdapter(this));
            FinancePanel.setBounds(new Rectangle(100, 40, 425, 222));
            FinancePanel.setLayout(null);
            FinanceLabel.setText("销售总额:");
            FinanceLabel.setBounds(new Rectangle(139, 102, 60, 33));
            FinanceTextField.setEnabled(false);
            FinanceTextField.setText("");
            FinanceTextField.setBounds(new Rectangle(193, 107, 110, 25));
            jContentPane.add(AddtoMenuButton);
            jContentPane.add(AddMenuPanel);
            AddMenuPanel.add(FoodNameTextField);
	        AddMenuPanel.add(PriceTextField);
	        AddMenuPanel.add(PriceLabel);
	        AddMenuPanel.add(CancelButton);
	        AddMenuPanel.add(OKButton);
	        AddMenuPanel.add(FoodNameLabel);
	        jContentPane.add(MenuViewButton);
            jContentPane.add(MenuViewPanel);
            jContentPane.add(CustomerViewButton);
            jContentPane.add(CustomerViewPanel);
            jContentPane.add(FinancePanel);
            FinancePanel.add(FinanceLabel);
            FinancePanel.add(FinanceTextField);
            jContentPane.add(FinanceButton);
            CustomerViewPanel.getViewport().add(CustomerViewTable);
            MenuViewPanel.getViewport().add(MenuViewTable);
            AddMenuPanel.setVisible(false);
            MenuViewPanel.setVisible(false);
            CustomerViewPanel.setVisible(false);
            FinancePanel.setVisible(false);
        }
        public void setCenter() {
            Toolkit kit = Toolkit.getDefaultToolkit();
            Dimension screenSize = kit.getScreenSize();
            int width = screenSize.width;
            int height = screenSize.height;
            final int WIDTH = 705;
            final int HEIGHT = 600;
            int x = (width - WIDTH) / 2;
            int y = (height - HEIGHT) / 2;
            setLocation(x, y);
        }

        /**
         * This method initializes jContentPane
         *
         * @return javax.swing.JPanel
         */
        private JPanel getJContentPane() {
            if (jContentPane == null) {
                note_jLabel = new JLabel();
                note_jLabel.setBounds(new Rectangle(83, 68, 338, 18));
                note_jLabel.setText("Please choose where to go.");
                jContentPane = new JPanel();
                jContentPane.setLayout(null);

                jContentPane.add(getPersonalbank(), null);
                jContentPane.add(getBankPanel(), null);
                jContentPane.add(getBankenterPanel(), null);
                jContentPane.add(getRegaccountPanel(), null);
                jContentPane.add(note_jLabel, null);

                bankenterPanel.setVisible(false);
                regaccountPanel.setVisible(false);
                bankPanel.setVisible(false);

            }
            return jContentPane;
        }

        /**
         * This method initializes personalbank
         *
         * @return javax.swing.JButton
         */
        private JButton getPersonalbank() { //进入银行
            if (personalbank == null) {
                personalbank = new JButton("银行");
                personalbank.setBounds(new Rectangle(47, 21, 98, 28));
                personalbank.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        // TODO Auto-generated Event stub actionPerformed()
                        note_jLabel.setText("You are now in the bank.");
                        AddMenuPanel.setVisible(false);
                        MenuViewPanel.setVisible(false);
                        CustomerViewPanel.setVisible(false);
                        FinancePanel.setVisible(false);
                        if (iflog) {
                            bankenterPanel.setVisible(false);
                            bankPanel.setVisible(true);
                        } else {
                            bankenterPanel.setVisible(true);
                            bankPanel.setVisible(false);
                        }
                    }
                });
            }
            return personalbank;
        }


        private JPanel getBankPanel() { //成功登录后的面板
            if (bankPanel == null) {
                jLabel8 = new JLabel();
                jLabel8.setBounds(new Rectangle(222, 83, 254, 40));
                jLabel8.setText("Welcome to the bank!");
                jLabel7 = new JLabel();
                jLabel7.setBounds(new Rectangle(208, 192, 31, 15));
                jLabel7.setText("");
                jLabel6 = new JLabel();
                jLabel6.setBounds(new Rectangle(193, 154, 49, 15));
                jLabel6.setText("");
                bankPanel = new JPanel();
                bankPanel.setLayout(null);
                bankPanel.setBounds(new Rectangle(28, 90, 662, 381)); /////////////////////////////
                bankPanel.add(getCheckaccount(), null);
                bankPanel.add(getDeposit(), null);
                bankPanel.add(getWithdraw(), null);

⌨️ 快捷键说明

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