1import java.awt.event.ActionEvent;
2import java.awt.event.ActionListener;
3import java.io.IOException;
4import java.io.PrintWriter;
6import java.net.UnknownHostException;
7import java.util.Scanner;
17 private PrintWriter
out;
25 this.socket =
new Socket(
"127.0.0.1", 58901);
26 this.in =
new Scanner(
socket.getInputStream());
27 this.out =
new PrintWriter(
socket.getOutputStream(),
true);
28 }
catch (UnknownHostException e) {
30 }
catch (IOException e) {
35 public void actionPerformed(ActionEvent actionEvent) {
37 System.out.println(
"Client Sent: UP");
43 public void actionPerformed(ActionEvent actionEvent) {
45 System.out.println(
"Client Sent: DOWN");
55 class ClinetHandler
extends Thread {
56 private Socket socket;
58 public ClinetHandler(Socket socket) {
66 }
catch (Exception e) {
71 public void readFromServer() throws Exception {
73 while (
in.hasNextLine()) {
74 var command =
in.nextLine();
75 System.out.println(
"Client Received: " + command);
79 }
catch (Exception e) {
ActionListener downButtonListener
ActionListener upButtonListener