?? userdialog.java
字號(hào):
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 = {"初級(jí)","中級(jí)","高級(jí)"};
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("請(qǐng)留尊姓大名。");
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;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -