📄 name_input.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Name_Input extends JDialog implements ActionListener
{
private JTextField text;
private JButton confirm;
private GameFace face;
public Name_Input(GameFace face)
{
setTitle(
"Please Enter Player Name:");
this.face=face;
Container c=getContentPane();
c.setLayout(new FlowLayout());
text=new JTextField(20);
text.addActionListener(this);
confirm=new JButton("OK");
confirm.addActionListener(this);
c.add(text);
c.add(confirm);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(300,100);
setLocation(240,200);
show();
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==text||e.getSource()==confirm)
{
String s=text.getText();
Communication.setName(s);
//Communication.setGameFace(face);
//Communication.init();
Communication.sendName();
//this.setVisible(false);
this.dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -