-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChoseFonctionnalite.java
More file actions
130 lines (121 loc) · 4.77 KB
/
ChoseFonctionnalite.java
File metadata and controls
130 lines (121 loc) · 4.77 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ui;
import Util.client.InitClient;
import Util.server.InitServer;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* @author HP
*/
public class ChoseFonctionnalite {
Stage stage;
public ChoseFonctionnalite(Stage stage){
this.stage = stage;
initUI();
}
private void initUI() {
Pane root = new Pane();
root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,new BackgroundSize(530, 400, true, true, true, true))));
JFXButton serveur = new JFXButton("SERVEUR");
serveur.setCursor(Cursor.HAND);
serveur.setMinSize(171, 57);
serveur.setLayoutX(179);
serveur.setLayoutY(90);
serveur.setFont(new Font(27));
serveur.setStyle("-fx-background-color: #9E21FF;");
serveur.setOnAction(event -> {startServerMode();});
JFXButton client = new JFXButton("CLIENT");
client.setCursor(Cursor.HAND);
client.setMinSize(171, 57);
client.setLayoutX(179);
client.setLayoutY(197);
client.setFont(new Font(27));
client.setStyle("-fx-background-color: #9E21FF;");
client.setOnAction(event -> {startClientMode(event);});
Label info = new Label("choisir la maniere d'utiliser virtual remote");
info.setMinSize(529, 43);
info.setLayoutX(10);
info.setLayoutY(14);
info.setFont(new Font("Algerian", 20));
root.getChildren().add(client);
root.getChildren().add(serveur);
root.getChildren().add(info);
Scene scene = new Scene(root, 530, 400);
stage.setTitle("Fontionnalité");
stage.setScene(scene);
stage.setResizable(false);
stage.initStyle(StageStyle.DECORATED);
stage.setOnCloseRequest(event->{System.exit(1);});
stage.show();
}
private void startServerMode() {
InitServer initializeServer = new InitServer(stage);
}
private void startClientMode(ActionEvent eventT) {
//File config = new File("resource/config.json");
String host="";
String port="8000";
Stage stageModal = new Stage();
Pane root =new Pane();
root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,new BackgroundSize(530, 400, true, true, true, true))));
stageModal.setScene(new Scene(root,200,200));
stageModal.initStyle(StageStyle.UTILITY);
Label adresse = new Label("Adresse serveur:");
adresse.setLayoutX(10);
adresse.setLayoutY(10);
adresse.setFont(Font.font("Arial", 16));
JFXTextField adresseInput = new JFXTextField("127.0.0.1");
adresseInput.setPrefWidth(180);
adresseInput.setLayoutX(10);
adresseInput.setLayoutY(40);
JFXButton valider = new JFXButton("Se connecter");
valider.setCursor(Cursor.HAND);
valider.setMinSize(100, 30);
valider.setLayoutX(20);
valider.setLayoutY(130);
valider.setFont(new Font(20));
valider.setStyle("-fx-background-color: #9E21FF;");
valider.setOnAction(event -> {
if(adresseInput.getText()!=""){
stageModal.close();
InitClient initializeClient = new InitClient(stage,adresseInput.getText(),port);
}
});
root.getChildren().add(valider);
root.getChildren().add(adresse);
root.getChildren().add(adresseInput);
stageModal.setTitle("Adresse serveur");
stageModal.initModality(Modality.WINDOW_MODAL);
stageModal.initOwner(
((Node)eventT.getSource()).getScene().getWindow() );
stageModal.show();
}
}