application1.java

来自「The program in the languaje java」· Java 代码 · 共 52 行

JAVA
52
字号
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * package18.Application1
 * <P>
 * @author lomaky
 */
public class Application1 {

  /**
   * Constructor
   */
  public Application1() throws IOException {
    Socket s = new Socket ("127.0.0.1",4321);
    Frame frame = new lomakyChat ("Chat " + "127.0.0.1" + ":" + "4321",
                    s.getInputStream (), s.getOutputStream ());    
    
//    Frame frame = new lomakyChat();
    //Center the window
    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);
    frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
    frame.setVisible(true);
  }

  /**
   * main
   * @param args
   */
  public static void main(String[] args) throws IOException{
    try  {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    new Application1();
  }
}

⌨️ 快捷键说明

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