Bouton pour choix de type de connexion
This commit is contained in:
parent
6fb2e95c05
commit
4e188d0258
4 changed files with 57 additions and 39 deletions
|
@ -1 +0,0 @@
|
||||||
/chatapp/
|
|
|
@ -1,12 +1,12 @@
|
||||||
chatapp/Launcher.java
|
chatapp/Launcher.java
|
||||||
chatapp.Launcher
|
chatapp.Launcher
|
||||||
chatapp/View/ConnexionScreen.java
|
chatapp/View/Clavardage.java
|
||||||
chatapp.View.ConnexionScreen
|
chatapp.View.Clavardage
|
||||||
|
chatapp.View.Clavardage$1
|
||||||
chatapp/View/DemarrerSession.java
|
chatapp/View/DemarrerSession.java
|
||||||
chatapp.View.DemarrerSession
|
chatapp.View.DemarrerSession
|
||||||
chatapp/View/FenetreSession.java
|
chatapp/Protocol/RunnerEcouteUDP.java
|
||||||
chatapp.View.FenetreSession
|
chatapp.Protocol.RunnerEcouteUDP
|
||||||
chatapp.View.FenetreSession$1
|
|
||||||
chatapp/Model/Utilisateur.java
|
chatapp/Model/Utilisateur.java
|
||||||
chatapp.Model.Utilisateur
|
chatapp.Model.Utilisateur
|
||||||
chatapp/View/View_Utilisateurs.java
|
chatapp/View/View_Utilisateurs.java
|
||||||
|
@ -28,12 +28,12 @@ chatapp/Controller/ChatApp.java
|
||||||
chatapp.Controller.ChatApp
|
chatapp.Controller.ChatApp
|
||||||
chatapp/Main.java
|
chatapp/Main.java
|
||||||
chatapp.Main
|
chatapp.Main
|
||||||
chatapp/View/Clavardage.java
|
|
||||||
chatapp.View.Clavardage
|
|
||||||
chatapp.View.Clavardage$1
|
|
||||||
chatapp/Protocol/SessionClavardage.java
|
|
||||||
chatapp.Protocol.SessionClavardage
|
|
||||||
chatapp/Model/DataBase.java
|
chatapp/Model/DataBase.java
|
||||||
chatapp.Model.DataBase
|
chatapp.Model.DataBase
|
||||||
chatapp/Protocol/RunnerEcouteUDP.java
|
chatapp/Protocol/SessionClavardage.java
|
||||||
chatapp.Protocol.RunnerEcouteUDP
|
chatapp.Protocol.SessionClavardage
|
||||||
|
chatapp/View/FenetreSession.java
|
||||||
|
chatapp.View.FenetreSession
|
||||||
|
chatapp.View.FenetreSession$1
|
||||||
|
chatapp/View/ConnexionScreen.java
|
||||||
|
chatapp.View.ConnexionScreen
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.RadioButton;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
@ -21,6 +22,8 @@ public class ConnexionScreen {
|
||||||
public Button connexionButton;
|
public Button connexionButton;
|
||||||
|
|
||||||
public TextField pseudonyme;
|
public TextField pseudonyme;
|
||||||
|
public RadioButton remoteButton;
|
||||||
|
public RadioButton localButton;
|
||||||
|
|
||||||
@FXML // ResourceBundle that was given to the FXMLLoader
|
@FXML // ResourceBundle that was given to the FXMLLoader
|
||||||
private ResourceBundle resources;
|
private ResourceBundle resources;
|
||||||
|
@ -41,30 +44,34 @@ public class ConnexionScreen {
|
||||||
*/
|
*/
|
||||||
public void connexion(ActionEvent actionEvent) {
|
public void connexion(ActionEvent actionEvent) {
|
||||||
Boolean connexion = false;
|
Boolean connexion = false;
|
||||||
try {
|
if(this.localButton.isSelected()) {
|
||||||
connexion = ChatApp.getInstance().connexion(pseudonyme.getText());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(!connexion){
|
|
||||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
|
||||||
alert.setTitle("Connexion");
|
|
||||||
// Header Text: null
|
|
||||||
alert.setHeaderText(null);
|
|
||||||
alert.setContentText("Echec de Connexion: le pseudo "+pseudonyme.getText()+" est deja pris");
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Stage stage = (Stage) connexionButton.getScene().getWindow();
|
|
||||||
Parent root = null;
|
|
||||||
try {
|
try {
|
||||||
root = FXMLLoader.load(getClass().getResource("/fenetres/View_Menu.fxml"));
|
connexion = ChatApp.getInstance().connexion(pseudonyme.getText());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Scene scene = new Scene(root);
|
if (!connexion) {
|
||||||
stage.setScene(scene);
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
stage.show();
|
alert.setTitle("Connexion");
|
||||||
|
// Header Text: null
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.setContentText("Echec de Connexion: le pseudo " + pseudonyme.getText() + " est deja pris");
|
||||||
|
alert.showAndWait();
|
||||||
|
} else {
|
||||||
|
Stage stage = (Stage) connexionButton.getScene().getWindow();
|
||||||
|
Parent root = null;
|
||||||
|
try {
|
||||||
|
root = FXMLLoader.load(getClass().getResource("/fenetres/View_Menu.fxml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Scene scene = new Scene(root);
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// PARTIE CONNEXION DISTANTE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.RadioButton?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.control.ToggleGroup?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
@ -24,24 +26,34 @@
|
||||||
</Text>
|
</Text>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<HBox alignment="CENTER" prefHeight="304.0" prefWidth="600.0" style="-fx-background-color: #3299a8;">
|
<HBox alignment="CENTER" prefHeight="304.0" prefWidth="598.0" style="-fx-background-color: #3299a8;">
|
||||||
<children>
|
<children>
|
||||||
<GridPane alignment="CENTER" prefHeight="302.0" prefWidth="279.0">
|
<GridPane alignment="CENTER" prefHeight="275.0" prefWidth="448.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="254.19998168945312" minHeight="10.0" prefHeight="123.19998779296876" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="254.19998168945312" minHeight="10.0" prefHeight="111.80001831054688" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="217.80000152587894" minHeight="10.0" prefHeight="107.20001220703125" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="217.80000152587894" minHeight="10.0" prefHeight="69.39998168945314" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="217.80000152587894" minHeight="10.0" prefHeight="33.60002441406249" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="217.80000152587894" minHeight="10.0" prefHeight="27.400000000000034" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="217.80000152587894" minHeight="10.0" prefHeight="79.39999999999998" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="pseudonyme" prefHeight="26.0" prefWidth="447.0" promptText="Pseudonyme" GridPane.columnSpan="2" />
|
<TextField fx:id="pseudonyme" prefHeight="26.0" prefWidth="447.0" promptText="Pseudonyme" GridPane.columnSpan="3" />
|
||||||
<Button fx:id="connexionButton" alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#connexion" prefHeight="38.0" prefWidth="287.0" style="-fx-background-color: #b0c926;" text="Connexion" textFill="#3299a8" GridPane.columnSpan="2" GridPane.rowIndex="1">
|
<Button fx:id="connexionButton" alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#connexion" prefHeight="38.0" prefWidth="453.0" style="-fx-background-color: #b0c926;" text="Connexion" textFill="#3299a8" GridPane.columnSpan="3" GridPane.rowIndex="1">
|
||||||
<font>
|
<font>
|
||||||
<Font name="OCR A Extended" size="27.0" />
|
<Font name="OCR A Extended" size="27.0" />
|
||||||
</font>
|
</font>
|
||||||
</Button>
|
</Button>
|
||||||
|
<RadioButton fx:id="remoteButton" mnemonicParsing="false" selected="true" text="Connexion distante" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||||
|
<toggleGroup>
|
||||||
|
<ToggleGroup fx:id="lieu" />
|
||||||
|
</toggleGroup>
|
||||||
|
</RadioButton>
|
||||||
|
<RadioButton fx:id="localButton" mnemonicParsing="false" text="Connexion locale" toggleGroup="$lieu" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|
Loading…
Reference in a new issue