Esempio n. 1
0
  /** Creates new form AdminWindow */
  public AdminWindow(Socket _socket, String username) {
    initComponents();
    setTitle("Admin window");
    AdminUsername.setText(username);
    socket = _socket;
    try {
      streamOut = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
    } catch (IOException e1) {
      // TODO Auto-generated catch block
      System.out.println("Failed to open output stream.");
      e1.printStackTrace();
    }

    adminWindowThread = new AdminWindowThread(this, socket);
    adminWindowThread.start();

    /* posalji serveru zahtjev za friend listom */
    send("GIVEREGUSERS");

    this.setVisible(true);
    this.addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent e) {
            if (socket != null)
              try {
                socket.close();
              } catch (IOException ioe) {
                System.err.println("Error closing socket: " + ioe.getMessage());
              }
            Login.main(null); /* starta se ispocetka Login
                                (mora se bas startati main metoda, jer je tamo dodan listener
                                pri zatvaranju prozora, da se zatvori i socket/stream */
          }
        });
  }
Esempio n. 2
0
 public void stop() {
   try {
     if (streamOut != null) streamOut.close();
     if (socket != null) socket.close();
   } catch (IOException ioe) {
     System.err.println("Error closing ...");
     System.exit(0);
   }
   adminWindowThread.close();
 }