-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerButton.java
More file actions
40 lines (36 loc) · 1.52 KB
/
ServerButton.java
File metadata and controls
40 lines (36 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Final Game ServerButton Class
* @Author Ilya Kononov
* @Date = January 22 2023
* This class is a button that has text written ontop of it
* This type of button is sends a command to the server which the server will send something back to the client
* After the server sent back the command after recieving this buttons command the client will switch screens
*/
import java.awt.Color;
import javax.swing.JFrame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.PrintWriter;
public class ServerButton extends TextButton {
private PrintWriter output;
private String command;
public ServerButton(JFrame window, PrintWriter output, Text text, String command, Color inColor, Color outColor, Color hoverColor, int centerX, int y, int radius) {
super(window, null, "", text, inColor, outColor, hoverColor, centerX, y, radius);
this.output = output;
this.command = command;
}
// Mouse clicking actions
public class BasicMouseListener implements MouseListener{
public void mouseClicked(MouseEvent event) {
// If mouse clicks button switch to correct screen
if (mouseInside) {
Client.ServerWriter writer = new Client.ServerWriter(output);
writer.print(command);
}
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
}
}