mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
feat(ChatController): Fin création du layout
This commit is contained in:
parent
bf1099609c
commit
11032bda27
4 changed files with 44 additions and 3 deletions
|
|
@ -31,7 +31,7 @@ public class ChatApplication extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(ChatApplication.class.getResource("chat-view.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(ChatApplication.class.getResource("chat-view.fxml"));
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
Scene scene = new Scene(fxmlLoader.load(), 600, 400);
|
||||||
stage.setTitle("Chat @BOUCLY_Emi (B2GA)");
|
stage.setTitle("Chat @BOUCLY_Emi (B2GA)");
|
||||||
|
|
||||||
stage.getIcons().add(new Image(Objects.requireNonNull(ChatApplication.class.getResourceAsStream("rt.png"))));
|
stage.getIcons().add(new Image(Objects.requireNonNull(ChatApplication.class.getResourceAsStream("rt.png"))));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package rtgre.chat;
|
package rtgre.chat;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.Observable;
|
||||||
|
import javafx.event.Event;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
|
@ -7,6 +10,7 @@ import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
@ -25,6 +29,10 @@ public class ChatController implements Initializable {
|
||||||
public ListView postListView;
|
public ListView postListView;
|
||||||
public ListView roomsListView;
|
public ListView roomsListView;
|
||||||
public ListView contactListView;
|
public ListView contactListView;
|
||||||
|
public TextField messageTextField;
|
||||||
|
public Button sendButton;
|
||||||
|
public Label statusLabel;
|
||||||
|
public Label dateTimeLabel;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -34,5 +42,38 @@ public class ChatController implements Initializable {
|
||||||
Image image = new Image(Objects.requireNonNull(ChatController.class.getResourceAsStream("anonymous.png")));
|
Image image = new Image(Objects.requireNonNull(ChatController.class.getResourceAsStream("anonymous.png")));
|
||||||
this.avatarImageView.setImage(image);
|
this.avatarImageView.setImage(image);
|
||||||
|
|
||||||
|
Thread dateTimeLoop = new Thread(this::dateTimeLoop);
|
||||||
|
dateTimeLoop.setDaemon(true);
|
||||||
|
dateTimeLoop.start();
|
||||||
|
|
||||||
|
hostComboBox.getItems().addAll("localhost:2024");
|
||||||
|
hostComboBox.getItems().addAll("localhost:2025");
|
||||||
|
hostComboBox.setValue("localhost:2024");
|
||||||
|
hostComboBox.setOnAction(this::statusNameUpdate);
|
||||||
|
|
||||||
|
statusLabel.setText("not connected to " + hostComboBox.getValue());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void statusNameUpdate(Event event) {
|
||||||
|
statusLabel.setText("not connected to " + hostComboBox.getValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void dateTimeLoop() {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
String datetime = "%1$ta %1$te %1$tb %1$tY - %1$tH:%1$tM".formatted(new Date());
|
||||||
|
// System.out.println(datetime);
|
||||||
|
Platform.runLater(() -> dateTimeLabel.setText(datetime));
|
||||||
|
Thread.sleep(60000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
<HBox>
|
<HBox>
|
||||||
<children>
|
<children>
|
||||||
<Label text="Status : " />
|
<Label text="Status : " />
|
||||||
<Label fx:id="statusLabel" text="Not connected" />
|
<Label fx:id="statusLabel" text="Not connected"/>
|
||||||
<Separator maxWidth="1.7976931348623157E308" orientation="VERTICAL" HBox.hgrow="ALWAYS" />
|
<Separator maxWidth="1.7976931348623157E308" orientation="VERTICAL" HBox.hgrow="ALWAYS" />
|
||||||
<Label fx:id="dateTimeLabel" text="Today" />
|
<Label fx:id="dateTimeLabel" text="Today" />
|
||||||
</children>
|
</children>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
||||||
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
||||||
|
|
||||||
# Nom du fichier de logs
|
# Nom du fichier de logs
|
||||||
java.util.logging.FileHandler.pattern=out/java%u.log
|
java.util.logging.FileHandler.pattern=../out/java%u.log
|
||||||
|
|
||||||
# Format de logs plus compact sur 1 seule ligne
|
# Format de logs plus compact sur 1 seule ligne
|
||||||
java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL | %4$-7s | %2$s | %5$s %6$s%n
|
java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL | %4$-7s | %2$s | %5$s %6$s%n
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue