📄 checkinconfirmframe.java
字号:
package view.mainframe.guestregister.guestcheckinframe;
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 CheckInConfirmFrame extends JFrame implements ActionListener {
private static CheckInConfirmFrame instance;
private JPanel jContentPane = null;
private JButton confirmButton = null;
public static void main(String[] args) {
CheckInConfirmFrame cf = new CheckInConfirmFrame();
}
public static CheckInConfirmFrame getInstance() {
if (instance == null) {
instance = new CheckInConfirmFrame();
}
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());
}
private CheckInConfirmFrame() {
super();
initialize();
}
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) {
CheckInConfirmFrame temp = (CheckInConfirmFrame) e.getWindow();
temp.setVisible(false);
temp.dispose();
MainFrame.getInstance().refresh();
}
});
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getConfirmButton(), null);
}
return jContentPane;
}
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 + -