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

📄 chatframe.java

📁 这是一个功能不错的多人聊天室.可以多人联机
💻 JAVA
字号:
package net.yangzhe.chatSocket;
import java.awt.BorderLayout;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.swing.JPanel;
import javax.swing.JFrame;

public class ChatFrame extends JFrame {

	private JPanel jContentPane = null;
	private ChatClientPanel chatClient = null;
	private String sip;
	private String nickname;
	/**
	 * This is the default constructor
	 * @param uname 
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	public ChatFrame(String ip, String uname) throws UnknownHostException, IOException {
		super();
		nickname=uname;
		sip=ip;
		initialize();
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		
		
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	private void initialize() throws UnknownHostException, IOException {
		this.setSize(547, 475);
		this.setLocation(new java.awt.Point(300,300));
		this.setContentPane(getJContentPane());
		this.setTitle("聊天室 网通实验 ");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	private JPanel getJContentPane() throws UnknownHostException, IOException {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getChatClient(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes chatClient	
	 * 	
	 * @return ChatClient	
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	private ChatClientPanel getChatClient() throws UnknownHostException, IOException {
		if (chatClient == null) {
			chatClient = new ChatClientPanel(sip,nickname);
			
		}
		return chatClient;
	}
	public static void main(String[] args) throws UnknownHostException, IOException{
		//Client cclient = new Client(InetAddress.getByName();
		ChatFrame  a=new ChatFrame("127.0.0.1","test");
		a.show();
	}

}  //  @jve:decl-index=0:visual-constraint="10,14"

⌨️ 快捷键说明

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