📄 userdialog.java
字号:
package nicholas.game.mine;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class UserDialog extends JDialog implements ActionListener {
private JButton confirmButton;
private JTextField nameField;
private String[] level = {"初级","中级","高级"};
private static String name;
public UserDialog(JFrame frame, int l, String n) {
super(frame, "新记录",true);
getContentPane().setLayout(null);
JLabel textLabel = new JLabel("已破"+level[l]+"记录,");
textLabel.setBounds(30,5,100,20);
getContentPane().add(textLabel,null);
textLabel = new JLabel("请留尊姓大名。");
textLabel.setBounds(30,25,100,20);
getContentPane().add(textLabel,null);
nameField = new JTextField(n);
nameField.setBounds(10,60,120,20);
nameField.selectAll();
getContentPane().add(nameField,null);
confirmButton = new JButton("确定");
confirmButton.addActionListener(this);
confirmButton.setBounds(40,90,60,25);
getContentPane().add(confirmButton,null);
this.setUndecorated(true);
setSize(145,130);
setLocationRelativeTo(frame);
setResizable(false);
show();
}
public void actionPerformed(ActionEvent e) {
name = nameField.getText();
dispose();
}
public static String showInputNameDialog(JFrame frame, int l, String n) {
UserDialog dialog = new UserDialog(frame, l, n);
return name;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -