📄 tipsdialog.java
字号:
package librarysearchingsystem;
import javax.swing.JDialog;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class TipsDialog extends JDialog implements ActionListener,
Runnable {
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
private int width = 220;
private final int height = 140;
private boolean resize = false;
private String message = "学号或密码有误";
// Frame f;
public TipsDialog() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public TipsDialog(String message) {
this.message = message;
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public TipsDialog(String message, boolean resize) {
this.message = message;
this.resize = resize;
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
TipsDialog wr = new TipsDialog();
}
private void jbInit() throws Exception {
this.getContentPane().setBackground(new Color(173, 138, 187));
this.setName("");
// this.setResizable(false);
if (resize) {
width = message.length() * 20+20;
}
this.setSize(width, height);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width - width) / 2, (d.height - height) / 2);
this.getContentPane().setLayout(borderLayout1);
jLabel1.setFont(new java.awt.Font("华文行楷", Font.PLAIN, 20));
jLabel1.setBorder(null);
jLabel1.setText(message);
jLabel1.setHorizontalAlignment(JLabel.CENTER);
jButton1.setFont(new java.awt.Font("隶书", Font.PLAIN, 14));
jButton1.setText("确 认");
this.getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
jPanel1.setBackground(new Color(228, 187, 225));
jPanel1.add(jButton1);
this.getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER);
jButton1.addActionListener(this);
Thread t = new Thread(this);
t.start();
this.setModal(true);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
this.dispose();
}
public void run() {
try {
Thread.sleep(3000);
this.dispose();
} catch (InterruptedException ex) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -