⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 name_input.java

📁 软件工程实践课程的答案哦
💻 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 + -