コード例 #1
0
ファイル: Client.java プロジェクト: isplendid/chat_room
  public Client(String destinationIP, String serverIP, int PORT, JTable friendTable) {
    this.friendTable = friendTable;
    this.destinationIP = destinationIP;

    frame = new JFrame("聊天室");
    try {
      // 构建界面
      initUI();

      // 创建连接 跟server连接SERVER_IP
      socket = new Socket(serverIP, PORT);

      // 发送信息
      /*InetAddress addr = InetAddress.getLocalHost();
      myIP = addr.getHostAddress().toString();*/

      myIP = LocalHost.getLocalIP();
      chartTextArea.append("本机IP:" + myIP + "\n");

      final Message message = new Message();
      message.setSendIP(myIP);
      message.setReceiveIP(destinationIP);
      sendMsgTextField.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (e.getSource() == sendMsgTextField) {
                new SendMsg(socket, message, sendMsgTextField, chartTextArea);
                sendMsgTextField.setText("");
              }
            }
          });
      sendButton.addActionListener(new SendMsg(socket, message, sendMsgTextField, chartTextArea));

    } catch (UnknownHostException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    this.start();
  }
コード例 #2
0
ファイル: SSHInfo.java プロジェクト: Droop/DimaX
 private void setDefaultDir() {
   this.dir = LocalHost.getDir();
 }
コード例 #3
0
ファイル: SSHInfo.java プロジェクト: Droop/DimaX
 protected boolean isLocal() {
   return this.url.equals(LocalHost.getUrl());
 }