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

📄 newuserdialog.java

📁 是一款国外的网络游戏平台的源码*不是类似浩方那种虚拟局域网技术
💻 JAVA
字号:
/*
 * Created on Jan 12, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.GTADS.client;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;

import org.GTADS.protocol.MetaData;
import org.GTADS.client.swing.*;

/**
 * @author sday
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class NewUserDialog extends GTADSFrame implements ActionListener {
	public static NewUserDialog instance;
	private GTADSPanel mainPanel = new GTADSPanel();
	private GTADSPanel panel1 = new GTADSPanel();
	private GTADSPanel panel2 = new GTADSPanel();
	private GTADSPanel panel3 = new GTADSPanel();
	private GTADSPanel panel4 = new GTADSPanel();
	private GTADSTextField newUserName = new GTADSTextField();
	private GTADSPasswordField newPassword = new GTADSPasswordField();
	private GTADSPasswordField confirmPassword = new GTADSPasswordField();
	private GTADSButton okButton = new GTADSButton("Ok");
	private GTADSButton cancelButton = new GTADSButton("Cancel");
	
	public static NewUserDialog getInstance(){
		if (instance == null){
			instance = new NewUserDialog();
		}
		return instance;
	}
	
	public static void clearInstance(){
		if (instance != null){
			instance.hide();
			instance.dispose();
			instance = null;
		}
	}
	
	public NewUserDialog (){
		createWindow();
	}
	
	private void createWindow() {
		this.setTitle("New Account");
		mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
		setupComponents();
		
		GTADSPanel titlePanel = new GTADSPanel();
		
		titlePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
		
		titlePanel.add(new GTADSLabel("Create a new Account"));
		panel1.add(new GTADSLabel("Username: "));
		panel1.add(newUserName);
		panel2.add(new GTADSLabel("Password: "));
		panel2.add(newPassword);
		panel3.add(new GTADSLabel("Confirm: "));
		panel3.add(confirmPassword);
		panel4.add(okButton);
		panel4.add(Box.createHorizontalStrut(5));
		panel4.add(cancelButton);
		
		mainPanel.add(titlePanel);
		mainPanel.add(panel1);
		mainPanel.add(panel2);
		mainPanel.add(panel3);
		mainPanel.add(panel4);
		
		setContentPane(mainPanel);
		show();
	}
	
	private void setupComponents(){
		this.setSize(300,250);
		panel1.setLayout(new FlowLayout(FlowLayout.LEFT));
		panel2.setLayout(new FlowLayout(FlowLayout.LEFT));
		panel3.setLayout(new FlowLayout(FlowLayout.LEFT));
		panel4.setLayout(new FlowLayout(FlowLayout.LEFT));
		
		newUserName.setColumns(15);
		newPassword.setColumns(15);
		confirmPassword.setColumns(15);
		
		okButton.addActionListener(this);
		cancelButton.addActionListener(this);
		
		
		
		this.setResizable(false);
	}
	
	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent evt) {
		if (evt.getSource().equals(okButton)){
			new ClientConnectionHandler(MetaData.NEW_USER_ACCT, MetaData.NEW_USER_ACCT, 
					(String)ClientLoginScreen.getInstance().serverList.getSelectedItem());
		}
		else if (evt.getSource().equals(cancelButton)){
			NewUserDialog.clearInstance();
		}

	}
	
	public String getNewUser(){
		return newUserName.getText();
	}
	
	public String getNewPassword(){
		return newPassword.getText();
	}
	public static void main(String arg[]){
		NewUserDialog.getInstance();
	}
}

⌨️ 快捷键说明

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