예제 #1
0
  public LoginBox() {
    super("VnmrJ Login");

    dolayout("", "", "");
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    // setVast();
    DisplayOptions.addChangeListener(this);

    try {
      InetAddress inetAddress = InetAddress.getLocalHost();
      m_strHostname = inetAddress.getHostName();
    } catch (Exception e) {
      m_strHostname = "localhost";
    }

    VNMRFrame vnmrFrame = VNMRFrame.getVNMRFrame();
    Dimension size = vnmrFrame.getSize();
    position = vnmrFrame.getLocationOnScreen();
    AppIF appIF = Util.getAppIF();
    int h = appIF.statusBar.getSize().height;
    width = size.width;
    height = size.height - h;

    // Allow resizing and use the previous size and position
    // To stop resizing, use setResizable(false);
    readPersistence();

    //        setSize(width, height);
    //        setLocation(position);
    //        setResizable(false);

    setBackgroundColor(Util.getBgColor());

    m_trayTimer =
        new javax.swing.Timer(
            6000,
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                setTrays();
              }
            });
  }
예제 #2
0
    @Override
    public void run() {

      try {
        // Create a server socket
        ServerSocket serverSocket = new ServerSocket(8000);
        textArea.append("TCP connection listener started at " + new Date() + '\n');

        while (true) {

          // Listen for a new connection request
          Socket socket = serverSocket.accept();

          // Display the client number
          textArea.append(
              "Starting thread for TCP client " + clientNo + " at " + new Date() + '\n');

          // Find the client's host name, and IP address
          InetAddress inetAddress = socket.getInetAddress();
          textArea.append(
              "Client " + clientNo + "'s host name is " + inetAddress.getHostName() + "\n");
          textArea.append(
              "Client " + clientNo + "'s IP Address is " + inetAddress.getHostAddress() + "\n");

          // Create a new thread for the TCP connection
          HandleTCPClient task = new HandleTCPClient(socket);

          // Start the new thread
          new Thread(task).start();

          // Increment clientNo
          clientNo++;
        }

      } catch (IOException ex) {
        System.err.println(ex);
      }
    }