feat(graphique): Création environnement graphique, taille minimale, importation fx:id => attribut

This commit is contained in:
bouclyma 2024-12-05 09:47:26 +01:00
parent da87040ec2
commit 8360fd9982
3 changed files with 134 additions and 16 deletions

View file

@ -13,6 +13,8 @@ public class ChatApplication extends Application {
FXMLLoader fxmlLoader = new FXMLLoader(ChatApplication.class.getResource("chat-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Chat @BOUCLY_Emi (B2GA)");
stage.setMinWidth(800);
stage.setMinHeight(500);
stage.setScene(scene);
stage.show();
}

View file

@ -1,14 +1,23 @@
package rtgre.chat;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
public class ChatController {
@FXML
private Label welcomeText;
@FXML
protected void onHelloButtonClick() {
welcomeText.setText("Welcome to JavaFX Application!");
}
public MenuItem hostAddMenuItem;
public MenuItem avatarMenuItem;
public MenuItem aboutMenuItem;
public ComboBox hostComboBox;
public TextField loginTextField;
public ToggleButton connectionButton;
public ImageView avatarImageView;
public SplitPane exchangeSplitPane;
public ListView postListView;
public ListView roomsListView;
public ListView contactListView;
}

View file

@ -1,16 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
fx:controller="rtgre.chat.ChatController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding>
<Label fx:id="welcomeText"/>
<Button text="Hello!" onAction="#onHelloButtonClick"/>
<VBox alignment="CENTER" minHeight="500.0" minWidth="800.0" prefHeight="500.0" prefWidth="800.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/18" fx:controller="rtgre.chat.ChatController">
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem fx:id="hostAddMenuItem" mnemonicParsing="false" text="Add host" />
<MenuItem fx:id="avatarMenuItem" mnemonicParsing="false" text="Change avatar" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem fx:id="aboutMenuItem" mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="NEVER" maxWidth="94.0" minWidth="10.0" prefWidth="59.0" />
<ColumnConstraints hgrow="NEVER" maxWidth="286.0" minWidth="0.0" prefWidth="32.0" />
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="494.0" />
<ColumnConstraints halignment="RIGHT" hgrow="NEVER" maxWidth="131.0" minWidth="10.0" prefWidth="106.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Server :" />
<Label text="Login :" GridPane.rowIndex="1" />
<ComboBox fx:id="hostComboBox" maxWidth="1.7976931348623157E308" promptText="Choose host..." GridPane.columnIndex="2">
<GridPane.margin>
<Insets bottom="5.0" top="5.0" />
</GridPane.margin>
</ComboBox>
<TextField fx:id="loginTextField" maxWidth="1.7976931348623157E308" GridPane.columnIndex="2" GridPane.rowIndex="1">
<GridPane.margin>
<Insets bottom="5.0" top="5.0" />
</GridPane.margin>
</TextField>
<ToggleButton fx:id="connectionButton" maxHeight="1.7976931348623157E308" mnemonicParsing="false" prefWidth="100.0" text="Connection" GridPane.columnIndex="3" GridPane.rowSpan="2">
<GridPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</GridPane.margin>
</ToggleButton>
<ImageView fx:id="avatarImageView" fitHeight="35.0" fitWidth="34.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.rowIndex="1" />
</children>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</VBox.margin>
</GridPane>
<SplitPane fx:id="exchangeSplitPane" dividerPositions="0.5" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
<items>
<ListView fx:id="postListView" prefHeight="200.0" prefWidth="348.0" />
<SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0">
<items>
<ListView fx:id="roomsListView" prefHeight="200.0" prefWidth="200.0" />
<ListView fx:id="contactListView" prefHeight="200.0" prefWidth="200.0" />
</items>
</SplitPane>
</items>
</SplitPane>
<HBox>
<children>
<Label text="Message :">
<padding>
<Insets bottom="5.0" left="5.0" top="5.0" />
</padding>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Label>
<TextField fx:id="messageTextField" HBox.hgrow="ALWAYS">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<HBox.margin>
<Insets bottom="5.0" right="5.0" top="5.0" />
</HBox.margin>
</TextField>
<Button fx:id="sendButton" mnemonicParsing="false" text="Send">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Button>
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox>
<children>
<Label text="Status : " />
<Label fx:id="statusLabel" text="Not connected" />
<Separator maxWidth="1.7976931348623157E308" orientation="VERTICAL" HBox.hgrow="ALWAYS" />
<Label fx:id="dateTimeLabel" text="Today" />
</children>
</HBox>
</children>
</VBox>