首页>代码>java swing聊天室代码>/jq/src/client/ClientMain.java
/**
 * ClassName: ClientMain.java
 * Author: qiujy
 * CreateTime: 2009-4-15
 * EMAIL: qjyong@gmail.com
 * Copyright 2009 ++YONG All rights reserved.
 */
package client;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.jvnet.substance.skin.*;
import client.ui.LoginFrame;

/** 客户端入口类 */
public class ClientMain {

	public static void main(String[] args) {
		connection(); //连接到服务器
		
		//设置外观感觉
		JFrame.setDefaultLookAndFeelDecorated(true);
		JDialog.setDefaultLookAndFeelDecorated(true);
		try {
			//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
			UIManager.setLookAndFeel(new SubstanceOfficeSilver2007LookAndFeel());
			UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		new LoginFrame();  //启动登录窗体
	}

	/** 连接到服务器 */
	public static void connection() {
		String ip = DataBuffer.configProp.getProperty("ip");
		int port = Integer.parseInt(DataBuffer.configProp.getProperty("port"));
		try {
			DataBuffer.clientSeocket = new Socket(ip, port);
			DataBuffer.oos = new ObjectOutputStream(DataBuffer.clientSeocket.getOutputStream());
			DataBuffer.ois = new ObjectInputStream(DataBuffer.clientSeocket.getInputStream());
			
		} catch (Exception e) {
			JOptionPane.showMessageDialog(new JFrame(), 
					"连接服务器失败,请检查!","服务器未连上", JOptionPane.ERROR_MESSAGE);//否则连接失败
			System.exit(0);
		}
	}
}
最近下载更多
WenMeng  LV9 2024年12月30日
13133117021  LV5 2024年12月24日
矿泉水  LV30 2024年10月8日
你们的代码都是我的了  LV16 2024年4月29日
等风来2020  LV3 2023年12月10日
buhuia  LV4 2023年6月9日
yangguang  LV8 2022年12月28日
dongandmin  LV8 2022年12月10日
caohanren  LV11 2022年12月9日
daidin  LV11 2022年7月20日
最近浏览更多
gfbuhbaduiei 1月9日
暂无贡献等级
WenMeng  LV9 2024年12月30日
13133117021  LV5 2024年12月24日
MQ-EQW 2024年12月20日
暂无贡献等级
葫芦马戏  LV1 2024年12月11日
Sotouch  LV15 2024年12月9日
Wq1008611 2024年11月28日
暂无贡献等级
3263394665  LV9 2024年8月31日
interface  LV22 2024年8月10日
windy079 2024年7月1日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友