用JAVA开发的多用户聊天室希望能通过
源代码在线查看: chat.java
/***************************************************
* 程序文件名称: Chat.java
* 功能:多用户聊天室的客户端程序(主程序),
* 构造和设置应用程序窗体。
***************************************************/
import java.awt.BorderLayout;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Chat
{
boolean packFrame = false;
/**
* 构造函数,显示应用程序的窗体.
*/
public Chat() {
Frame1 frame = new Frame1();
// Validate frames that have preset sizes
// Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
} else {
frame.validate();
}
// 使窗体在屏幕居中显示
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
}
/**
*主函数,应用程序的入口.
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.
getSystemLookAndFeelClassName());
}
catch (Exception exception)
{ exception.printStackTrace(); }
new Chat();
} // run() end
}); // invokeLater()方法 end
}
}