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

📄 establishdialog.java

📁 完成黑白棋的开发
💻 JAVA
字号:
package BlackAndWhite;
import BlackAndWhite.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class establishDialog extends JDialog implements ActionListener
{
	private JPanel textP1,buttonP,noticeP;
	private JLabel nameL,noticeL;
	private JTextField nameT;
	private JButton yesB,noB;
	public String name;
	public boolean yes=false;

	public establishDialog(Frame owner)
	{
		super(owner,"连接游戏",true);    
		
		nameL=new JLabel(" 本 机 名");
		nameT=new JTextField("server",20);
		textP1=new JPanel();
		textP1.add(nameL);
		textP1.add(nameT);
		
		yesB=new JButton("确定");
		noB=new JButton("取消");
		buttonP=new JPanel();
		buttonP.add(yesB);
		buttonP.add(noB);
		yesB.addActionListener(this);
		noB.addActionListener(this);
		
		noticeL=new JLabel("主机信息");
		noticeP=new JPanel();
		noticeP.add(noticeL);
		
		getContentPane().setLayout(new GridLayout(3,1));    
		getContentPane().add(noticeP);
		getContentPane().add(textP1);                        
		getContentPane().add(buttonP);
		Point p;
		p=owner.getLocation();
		int x=(int)p.getX()+200;
		int y=(int)p.getY()+150;
		this.setLocation(x,y);
		this.setLocation(x,y);
		setResizable(false);
		pack();                                      
	}
	
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==yesB){
			name=nameT.getText();
			yes=true;
		}
		hide();                            
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -