trying to fix MVC
This commit is contained in:
parent
a75d3466ef
commit
28376f1242
|
@ -7,6 +7,7 @@ import ch.zhaw.pm2.multichat.protocol.NetworkHandler;
|
|||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -25,21 +26,33 @@ public class ChatWindowController {
|
|||
|
||||
private final WindowCloseHandler windowCloseHandler = new WindowCloseHandler();
|
||||
|
||||
@FXML private Pane rootPane;
|
||||
@FXML private TextField serverAddressField;
|
||||
@FXML private TextField serverPortField;
|
||||
@FXML private TextField userNameField;
|
||||
@FXML private TextField messageField;
|
||||
@FXML private TextArea messageArea;
|
||||
@FXML private Button connectButton;
|
||||
@FXML private Button sendButton;
|
||||
@FXML private TextField filterValue;
|
||||
@FXML
|
||||
private Pane rootPane;
|
||||
@FXML
|
||||
private TextField serverAddressField;
|
||||
@FXML
|
||||
private TextField serverPortField;
|
||||
@FXML
|
||||
private TextField userNameField;
|
||||
@FXML
|
||||
private TextField messageField;
|
||||
@FXML
|
||||
private TextArea messageArea;
|
||||
@FXML
|
||||
private Button connectButton;
|
||||
@FXML
|
||||
private Button sendButton;
|
||||
@FXML
|
||||
private TextField filterValue;
|
||||
|
||||
private ChatWindowModel model = new ChatWindowModel();
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
serverAddressField.setText(NetworkHandler.DEFAULT_ADDRESS.getCanonicalHostName());
|
||||
serverPortField.setText(String.valueOf(NetworkHandler.DEFAULT_PORT));
|
||||
serverAddressField.setText(model.getServerAddress()); // binding server address to view
|
||||
model.setServerAddress(NetworkHandler.DEFAULT_ADDRESS.getCanonicalHostName()); // sets modell adress
|
||||
serverPortField.setText(model.getServerPort());
|
||||
model.setServerPort(String.valueOf(NetworkHandler.DEFAULT_PORT));
|
||||
}
|
||||
|
||||
public void setMessages(ClientMessageList messages) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package ch.zhaw.pm2.multichat.client;
|
||||
|
||||
import javafx.beans.value.ObservableStringValue;
|
||||
|
||||
public class ChatWindowModel {
|
||||
private ClientConnectionHandler connectionHandler;
|
||||
private ClientMessageList messages;
|
||||
ObservableStringValue serverAddress;
|
||||
ObservableStringValue serverPort;
|
||||
|
||||
|
||||
public String getServerAddress() {
|
||||
return serverAddress.get();
|
||||
}
|
||||
|
||||
public void setServerAddress(String address) {
|
||||
setServerAddress(address);
|
||||
}
|
||||
|
||||
public String getServerPort() {
|
||||
return getServerPort();
|
||||
}
|
||||
|
||||
public void setServerPort(String address) {
|
||||
setServerPort(address);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue