📄 checkoutconfirmframe.java
字号:
package view.mainframe.guestconsumed.guestcheckoutframe;
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 view.mainframe.MainFrame;
public class CheckOutConfirmFrame extends JFrame implements ActionListener {
private static CheckOutConfirmFrame instance;
private JPanel jContentPane = null;
private JButton confirmButton = null;
public static CheckOutConfirmFrame getInstance() {
if (instance == null) {
instance = new CheckOutConfirmFrame();
}
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 CheckOutConfirmFrame() {
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);
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
CheckOutConfirmFrame temp = (CheckOutConfirmFrame) 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) {
JButton jb = (JButton) e.getSource();
if (jb.getText().trim().equals("结账已成功")) {
this.setVisible(false);
this.dispose();
MainFrame.getInstance().refresh();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -