-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientLobbyController.java
114 lines (87 loc) · 2.71 KB
/
ClientLobbyController.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package assignment7;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
//import assignment7.ClientMain.UpdateableListViewSkin;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
public class ClientLobbyController implements Initializable {
@FXML
private ListView<String> lobbyChats;
@FXML
private ListView<String> lobbyClients;
@FXML
private Button startChat;
@FXML
private Button joinChat;
private ChatClient client;
private String selectedChat;
private String selectedClient;
public void setClient(ChatClient client) {
this.client = client;
}
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
lobbyChats.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
// TODO Auto-generated method stub
selectedChat = lobbyChats.getSelectionModel().getSelectedItem();
}
});
lobbyClients.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
// TODO Auto-generated method stub
if (arg0.getClickCount() == 2) {
System.out.println("PRIVATE MESSAGING...");
selectedClient = lobbyClients.getSelectionModel().getSelectedItem();
client.joinPrivateChat(selectedClient);
}
}
});
// TODO Auto-generated method stub
startChat.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
client.addChat();
}
});
joinChat.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println(selectedChat);
client.joinChat(selectedChat);
}
});
}
public void updateLobbyChats(ObservableList<String> list) {
Platform.runLater(new Runnable() {
@Override
public void run() {
lobbyChats.getItems().clear();
lobbyChats.setItems(list);
}
});
}
public void updateLobbyClients(ObservableList<String> list) {
Platform.runLater(new Runnable() {
@Override
public void run() {
lobbyClients.getItems().clear();
lobbyClients.setItems(list);
}
});
}
}