reservationconfirmframe.java

来自「一个KTV管理系统」· Java 代码 · 共 130 行

JAVA
130
字号
package view.mainframe.guestregister.reservationmanageframe;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import view.mainframe.MainFrame;

public class reservationConfirmFrame extends JFrame implements ActionListener {

	private static reservationConfirmFrame instance;

	private JPanel jContentPane = null;

	private JButton confirmButton = null;

	public static reservationConfirmFrame getInstance() {
		if (instance == null) {
			instance = new reservationConfirmFrame();
		}
		instance.setVisible(true);
		return instance;
	}

	// 设置窗口为居中位置
	private void setWindowLocation(Window w) {
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension windowSize = w.getSize();
		w.setBounds((int) (screenSize.getWidth() - windowSize.getWidth()) / 2,
				(int) (screenSize.getHeight() - windowSize.getHeight()) / 2,
				(int) windowSize.getWidth(), (int) windowSize.getHeight());
	}

	/**
	 * This is the default constructor
	 */
	private reservationConfirmFrame() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(272, 168);
		this.setContentPane(getJContentPane());
		this.setTitle("预订新增确认");
		setWindowLocation(this);
		this.setResizable(false);
		try {
			// UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
			UIManager
					.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
			// UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
			SwingUtilities.updateComponentTreeUI(this);

			// f.pack();
			this.setVisible(true);
		} catch (Exception el) {
			System.out.println("Look and Feel Exception");
			System.exit(0);
		}
		this.setVisible(true);
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				reservationConfirmFrame temp = (reservationConfirmFrame) e
						.getWindow();
				temp.setVisible(false);
				temp.dispose();
				MainFrame.getInstance().refresh();
			}
		});

	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getConfirmButton(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes confirmButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getConfirmButton() {
		if (confirmButton == null) {
			confirmButton = new JButton();
			confirmButton.setBounds(new java.awt.Rectangle(67, 40, 133, 36));
			confirmButton.setText("预订已成功");
			confirmButton.addActionListener(this);
		}
		return confirmButton;
	}

	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		JButton jb = (JButton) e.getSource();
		if (jb.getText().trim().equals("预订已成功")) {
			this.setVisible(false);
			this.dispose();
			MainFrame.getInstance().refresh();
		}
	}

} // @jve:decl-index=0:visual-constraint="246,55"

⌨️ 快捷键说明

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