├── lib
├── jfoenix-8.0.8.jar
└── fontawesomefx-8.9.jar
├── .idea
├── jfoenix-8.0.8.jar
├── vcs.xml
├── .gitignore
├── libraries
│ ├── jfoenix_8_0_8.xml
│ └── fontawesomefx_8_9.xml
├── compiler.xml
├── misc.xml
├── modules.xml
└── uiDesigner.xml
├── src
├── lk
│ └── play_tech
│ │ └── chat_application
│ │ ├── assets
│ │ ├── heart.png
│ │ ├── smile.png
│ │ ├── sad-face.png
│ │ └── main-image.jpg
│ │ ├── controller
│ │ ├── LoginForm01Controller.java
│ │ ├── LoginForm03Controller.java
│ │ ├── LoginForm02Controller.java
│ │ ├── Client03FormController.java
│ │ ├── Client02FormController.java
│ │ ├── Client01FormController.java
│ │ └── ServerFormController.java
│ │ ├── view
│ │ ├── login-form-01.fxml
│ │ ├── login-form-02.fxml
│ │ ├── login-form-03.fxml
│ │ ├── client-01-form.fxml
│ │ ├── client-02-form.fxml
│ │ ├── client-03-form.fxml
│ │ └── server-form.fxml
│ │ └── model
│ │ └── Client.java
├── ServerInitializer.java
├── Client02_Initializer.java
├── Client03_Initializer.java
└── Client01_Initializer.java
├── out
└── production
│ └── INP_Course_Work
│ ├── ServerInitializer.class
│ ├── Client01_Initializer.class
│ ├── Client02_Initializer.class
│ ├── Client03_Initializer.class
│ └── lk
│ └── play_tech
│ └── chat_application
│ ├── bo
│ ├── test.jpg
│ ├── test1.jpg
│ ├── test2.jpg
│ ├── test3.jpg
│ └── test4.jpg
│ ├── assets
│ ├── heart.png
│ ├── smile.png
│ ├── main-image.jpg
│ └── sad-face.png
│ ├── model
│ └── Client.class
│ ├── controller
│ ├── LoginForm01Controller.class
│ ├── LoginForm02Controller.class
│ ├── LoginForm03Controller.class
│ ├── ServerFormController.class
│ ├── Client01FormController$1.class
│ ├── Client01FormController.class
│ ├── Client02FormController$1.class
│ ├── Client02FormController.class
│ ├── Client03FormController$1.class
│ ├── Client03FormController.class
│ ├── ServerFormController$1.class
│ └── ServerFormController$2.class
│ └── view
│ ├── login-form-01.fxml
│ ├── login-form-02.fxml
│ ├── login-form-03.fxml
│ ├── client-01-form.fxml
│ ├── client-02-form.fxml
│ ├── client-03-form.fxml
│ └── server-form.fxml
├── README.md
└── INP_Course_Work.iml
/lib/jfoenix-8.0.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/lib/jfoenix-8.0.8.jar
--------------------------------------------------------------------------------
/.idea/jfoenix-8.0.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/.idea/jfoenix-8.0.8.jar
--------------------------------------------------------------------------------
/lib/fontawesomefx-8.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/lib/fontawesomefx-8.9.jar
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/assets/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/src/lk/play_tech/chat_application/assets/heart.png
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/assets/smile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/src/lk/play_tech/chat_application/assets/smile.png
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/ServerInitializer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/ServerInitializer.class
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/assets/sad-face.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/src/lk/play_tech/chat_application/assets/sad-face.png
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/Client01_Initializer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/Client01_Initializer.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/Client02_Initializer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/Client02_Initializer.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/Client03_Initializer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/Client03_Initializer.class
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/assets/main-image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/src/lk/play_tech/chat_application/assets/main-image.jpg
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test.jpg
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test1.jpg
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test2.jpg
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test3.jpg
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/bo/test4.jpg
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/heart.png
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/smile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/smile.png
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/model/Client.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/model/Client.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/main-image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/main-image.jpg
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/sad-face.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/assets/sad-face.png
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/LoginForm01Controller.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/LoginForm01Controller.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/LoginForm02Controller.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/LoginForm02Controller.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/LoginForm03Controller.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/LoginForm03Controller.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/ServerFormController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/ServerFormController.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client01FormController$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client01FormController$1.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client01FormController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client01FormController.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client02FormController$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client02FormController$1.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client02FormController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client02FormController.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client03FormController$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client03FormController$1.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client03FormController.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/Client03FormController.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/ServerFormController$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/ServerFormController$1.class
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/ServerFormController$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sandun-Induranga/Chat-Application/HEAD/out/production/INP_Course_Work/lk/play_tech/chat_application/controller/ServerFormController$2.class
--------------------------------------------------------------------------------
/.idea/libraries/jfoenix_8_0_8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/libraries/fontawesomefx_8_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Chat-Application
2 | Java Socket Programming
3 |
4 | *Technologies*
5 | * Java
6 | * JavaFX
7 | * CSS
8 | * Intellij Idea
9 | * Java Socket Programming
10 |
11 | 
12 |
--------------------------------------------------------------------------------
/src/ServerInitializer.java:
--------------------------------------------------------------------------------
1 | import javafx.application.Application;
2 | import javafx.fxml.FXMLLoader;
3 | import javafx.scene.Scene;
4 | import javafx.stage.Stage;
5 |
6 | import java.io.IOException;
7 |
8 | public class ServerInitializer extends Application {
9 |
10 | public static void main(String[] args) {
11 | launch(args);
12 | }
13 |
14 | @Override
15 | public void start(Stage primaryStage) throws IOException {
16 | primaryStage.setScene(new Scene(FXMLLoader.load(getClass().getResource("lk/play_tech/chat_application/view/server-form.fxml"))));
17 | primaryStage.setAlwaysOnTop(true);
18 | primaryStage.show();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Client02_Initializer.java:
--------------------------------------------------------------------------------
1 | import javafx.application.Application;
2 | import javafx.fxml.FXMLLoader;
3 | import javafx.scene.Scene;
4 | import javafx.stage.Stage;
5 |
6 | import java.io.IOException;
7 |
8 | public class Client02_Initializer extends Application {
9 |
10 | public static void main(String[] args) {
11 | launch(args);
12 | }
13 |
14 | @Override
15 | public void start(Stage primaryStage) throws IOException {
16 | primaryStage.setScene(new Scene(FXMLLoader.load(getClass().getResource("lk/play_tech/chat_application/view/login-form-02.fxml"))));
17 | primaryStage.setAlwaysOnTop(true);
18 | primaryStage.show();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Client03_Initializer.java:
--------------------------------------------------------------------------------
1 | import javafx.application.Application;
2 | import javafx.fxml.FXMLLoader;
3 | import javafx.scene.Scene;
4 | import javafx.stage.Stage;
5 |
6 | import java.io.IOException;
7 |
8 | public class Client03_Initializer extends Application {
9 |
10 | public static void main(String[] args) {
11 | launch(args);
12 | }
13 |
14 | @Override
15 | public void start(Stage primaryStage) throws IOException {
16 | primaryStage.setScene(new Scene(FXMLLoader.load(getClass().getResource("lk/play_tech/chat_application/view/login-form-03.fxml"))));
17 | primaryStage.setAlwaysOnTop(true);
18 | primaryStage.show();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Client01_Initializer.java:
--------------------------------------------------------------------------------
1 | import javafx.application.Application;
2 | import javafx.event.Event;
3 | import javafx.fxml.FXMLLoader;
4 | import javafx.scene.Scene;
5 | import javafx.stage.Stage;
6 | import javafx.stage.StageStyle;
7 |
8 | import java.io.IOException;
9 |
10 | public class Client01_Initializer extends Application {
11 |
12 | public static void main(String[] args) {
13 | launch(args);
14 | }
15 |
16 | @Override
17 | public void start(Stage primaryStage) throws IOException {
18 | primaryStage.setScene(new Scene(FXMLLoader.load(getClass().getResource("lk/play_tech/chat_application/view/login-form-01.fxml"))));
19 | // primaryStage.initStyle(StageStyle.UTILITY);
20 | primaryStage.setAlwaysOnTop(true);
21 | primaryStage.show();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/LoginForm01Controller.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.event.ActionEvent;
4 | import javafx.fxml.FXMLLoader;
5 | import javafx.scene.Scene;
6 | import javafx.scene.control.TextField;
7 | import javafx.scene.layout.AnchorPane;
8 | import javafx.stage.Stage;
9 |
10 | import java.io.IOException;
11 |
12 | public class LoginForm01Controller {
13 | public TextField txtName;
14 | public AnchorPane loginContext;
15 | public static String name;
16 |
17 | public void btnLoginOnAction(ActionEvent actionEvent) throws IOException {
18 | name = txtName.getText();
19 | loginContext.getChildren().clear();
20 | Stage stage = (Stage) loginContext.getScene().getWindow();
21 | stage.setScene(new Scene(FXMLLoader.load(getClass().getResource("../view/client-01-form.fxml"))));
22 | }
23 | }
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/LoginForm03Controller.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.event.ActionEvent;
4 | import javafx.fxml.FXMLLoader;
5 | import javafx.scene.Scene;
6 | import javafx.scene.control.TextField;
7 | import javafx.scene.layout.AnchorPane;
8 | import javafx.stage.Stage;
9 |
10 | import java.io.IOException;
11 |
12 | public class LoginForm03Controller {
13 | public TextField txtName;
14 | public AnchorPane loginContext;
15 | public static String name;
16 |
17 | public void btnLoginOnAction(ActionEvent actionEvent) throws IOException {
18 | name = txtName.getText();
19 | loginContext.getChildren().clear();
20 | Stage stage = (Stage) loginContext.getScene().getWindow();
21 | stage.setScene(new Scene(FXMLLoader.load(getClass().getResource("../view/client-03-form.fxml"))));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/INP_Course_Work.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/LoginForm02Controller.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.event.ActionEvent;
4 | import javafx.fxml.FXMLLoader;
5 | import javafx.scene.Scene;
6 | import javafx.scene.control.Label;
7 | import javafx.scene.control.TextField;
8 | import javafx.scene.layout.AnchorPane;
9 | import javafx.stage.Stage;
10 |
11 | import java.io.IOException;
12 | import java.util.ArrayList;
13 | import java.util.Objects;
14 |
15 | public class LoginForm02Controller {
16 | public TextField txtName;
17 | public AnchorPane loginContext;
18 | public static String name;
19 |
20 | public void btnLoginOnAction(ActionEvent actionEvent) throws IOException {
21 | name = txtName.getText();
22 | loginContext.getChildren().clear();
23 | Stage stage = (Stage) loginContext.getScene().getWindow();
24 | stage.setScene(new Scene(FXMLLoader.load(getClass().getResource("../view/client-02-form.fxml"))));
25 | }
26 | }
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/login-form-01.fxml:
--------------------------------------------------------------------------------
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 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/login-form-01.fxml:
--------------------------------------------------------------------------------
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 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/login-form-02.fxml:
--------------------------------------------------------------------------------
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 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/login-form-03.fxml:
--------------------------------------------------------------------------------
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 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/login-form-02.fxml:
--------------------------------------------------------------------------------
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 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/login-form-03.fxml:
--------------------------------------------------------------------------------
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 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/model/Client.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | import javax.imageio.stream.ImageInputStream;
9 | import java.io.*;
10 | import java.net.ServerSocket;
11 | import java.net.Socket;
12 |
13 | @AllArgsConstructor
14 | @NoArgsConstructor
15 | @Setter
16 | @Getter
17 | public class Client {
18 | private String name;
19 | private int port;
20 | private ServerSocket serverSocket;
21 | private Socket accept;
22 | private Socket imgSocket;
23 | private DataInputStream dataInputStream;
24 | private DataOutputStream dataOutputStream;
25 | private InputStream imgInputStream;
26 | private OutputStream imgOutputStream;
27 | private String message = "";
28 |
29 | public Client(int port) {
30 | this.port = port;
31 | }
32 |
33 | public void acceptConnection() throws IOException {
34 | serverSocket = new ServerSocket(port);
35 | this.accept = serverSocket.accept();
36 | }
37 |
38 | public void acceptImgConnection(int port) throws IOException {
39 | serverSocket = new ServerSocket(port);
40 | this.imgSocket = serverSocket.accept();
41 | }
42 |
43 | public void setInputAndOutput() throws IOException {
44 | this.dataInputStream = new DataInputStream(accept.getInputStream());
45 | this.dataOutputStream = new DataOutputStream(accept.getOutputStream());
46 | }
47 |
48 | public void setImageInputAndOutput() throws IOException {
49 | this.imgInputStream = imgSocket.getInputStream();
50 | this.imgOutputStream = imgSocket.getOutputStream();
51 | }
52 |
53 | public void processTextMessage() throws IOException {
54 | while (!message.equals("exit")) {
55 | message = "Client 1 : " + dataInputStream.readUTF();
56 | System.out.println(message);
57 | String typeName = dataInputStream.getClass().getTypeName();
58 | System.out.println(typeName);
59 |
60 | if (message.equals("Client 1 : exit")) {
61 | accept = null;
62 | return;
63 | }
64 | // sendTextMessage(message);
65 | }
66 | }
67 |
68 | private void sendTextMessage(String message) throws IOException {
69 | if (this.accept != null) {
70 | this.dataOutputStream.writeUTF(message.trim());
71 | this.dataOutputStream.flush();
72 | }
73 | }
74 |
75 | // @Override
76 | // public void run() {
77 | // try {
78 | //
79 | // } catch (IOException e) {
80 | // e.printStackTrace();
81 | // }
82 | // }
83 | }
84 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/client-01-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
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 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/client-01-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
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 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/client-02-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
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 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/client-03-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
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 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/client-02-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
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 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/client-03-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
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 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/view/server-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
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 |
--------------------------------------------------------------------------------
/out/production/INP_Course_Work/lk/play_tech/chat_application/view/server-form.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
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 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/Client03FormController.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.application.Platform;
4 | import javafx.embed.swing.SwingFXUtils;
5 | import javafx.event.ActionEvent;
6 | import javafx.scene.control.Label;
7 | import javafx.scene.control.ScrollPane;
8 | import javafx.scene.control.TextField;
9 | import javafx.scene.image.Image;
10 | import javafx.scene.image.ImageView;
11 | import javafx.scene.input.MouseEvent;
12 | import javafx.scene.layout.AnchorPane;
13 | import javafx.scene.layout.VBox;
14 | import javafx.stage.FileChooser;
15 | import javafx.stage.Stage;
16 |
17 | import javax.imageio.ImageIO;
18 | import java.awt.image.BufferedImage;
19 | import java.io.*;
20 | import java.net.Socket;
21 |
22 | public class Client03FormController {
23 | public ScrollPane msgContext;
24 | public TextField txtMessage;
25 | public AnchorPane context = new AnchorPane();
26 |
27 | final int PORT = 65000;
28 | public Label lblClient;
29 | public AnchorPane emoji;
30 | Socket socket;
31 | Socket imgSocket;
32 | DataInputStream dataInputStream;
33 | DataOutputStream dataOutputStream;
34 | String message = "";
35 | int i = 10;
36 | String path = "";
37 | public static boolean isImageChoose = false;
38 | File file;
39 | OutputStream imgOutputStream;
40 | InputStream imgInputStream;
41 | public static String name;
42 | boolean isUsed = false;
43 |
44 | public void initialize() {
45 | Platform.setImplicitExit(false);
46 | msgContext.setContent(context);
47 | msgContext.vvalueProperty().bind(context.heightProperty());
48 | msgContext.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
49 | msgContext.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
50 | lblClient.setText(LoginForm03Controller.name);
51 | name = lblClient.getText();
52 |
53 | new Thread(() -> {
54 | try {
55 | socket = new Socket("localhost", PORT);
56 |
57 | while (true) {
58 | dataOutputStream = new DataOutputStream(socket.getOutputStream());
59 | dataInputStream = new DataInputStream(socket.getInputStream());
60 | message = dataInputStream.readUTF();
61 | System.out.println(message);
62 |
63 | Platform.runLater(new Runnable() {
64 | @Override
65 | public void run() {
66 | if (message.startsWith("/")) {
67 | BufferedImage sendImage = null;
68 | try {
69 | sendImage = ImageIO.read(new File(message));
70 | } catch (IOException e) {
71 | e.printStackTrace();
72 | }
73 | Image img = SwingFXUtils.toFXImage(sendImage, null);
74 | ImageView imageView = new ImageView(img);
75 | imageView.setFitHeight(150);
76 | imageView.setFitWidth(150);
77 | imageView.setLayoutY(i);
78 | context.getChildren().add(imageView);
79 | i += 150;
80 | } else if (message.startsWith(LoginForm03Controller.name)) {
81 | message = message.replace(LoginForm03Controller.name, "You");
82 | Label label = new Label(message);
83 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #85b6ff; -fx-text-fill: #5c5c5c");
84 | label.setLayoutY(i);
85 | context.getChildren().add(label);
86 | } else {
87 | Label label = new Label(message);
88 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #CDB4DB; -fx-text-fill: #5c5c5c");
89 | label.setLayoutY(i);
90 | context.getChildren().add(label);
91 | }
92 | i += 30;
93 | }
94 | });
95 | }
96 | } catch (IOException e) {
97 | e.printStackTrace();
98 | }
99 | }).start();
100 |
101 | // new Thread(() -> {
102 | // try {
103 | // imgSocket = new Socket("localhost", PORT + 1);
104 | //
105 | // while (true) {
106 | // imgOutputStream = imgSocket.getOutputStream();
107 | // imgInputStream = imgSocket.getInputStream();
108 | // byte[] sizeAr = new byte[4];
109 | // imgInputStream.read(sizeAr);
110 | // int size = ByteBuffer.wrap(sizeAr).asIntBuffer().get();
111 | //
112 | // byte[] imageAr = new byte[size];
113 | // imgInputStream.read(imageAr);
114 | //
115 | // BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageAr));
116 | //
117 | // System.out.println("Received " + image.getHeight() + "x" + image.getWidth() + ": " + System.currentTimeMillis());
118 | // ImageIO.write(image, "jpg", new File("/media/sandu/0559F5C021740317/GDSE/Project_Zone/IdeaProjects/INP_Course_Work/src/lk/play_tech/chat_application/bo/test3.jpg"));
119 | // //BufferedImage sendImage = ImageIO.read(new File("/home/sandu/Downloads/296351115_1695464754171592_2138034279597586981_n.jpg"));
120 | //
121 | // Platform.runLater(new Runnable() {
122 | // @Override
123 | // public void run() {
124 | // Image img = SwingFXUtils.toFXImage(image, null);
125 | // ImageView imageView = new ImageView(img);
126 | // imageView.setFitHeight(150);
127 | // imageView.setFitWidth(150);
128 | // imageView.setLayoutY(100);
129 | // context.getChildren().add(imageView);
130 | // i += 120;
131 | // }
132 | // });
133 | // }
134 | // } catch (IOException e) {
135 | // e.printStackTrace();
136 | // }
137 | // }).start();
138 | }
139 |
140 | public void btnSendOnAction(MouseEvent actionEvent) throws IOException {
141 | //// if (isImageChoose){
142 | // BufferedImage image = ImageIO.read(new File(path));
143 | //
144 | // ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
145 | // ImageIO.write(image, "png", byteArrayOutputStream);
146 | //
147 | // byte[] size = ByteBuffer.allocate(4).putInt(byteArrayOutputStream.size()).array();
148 | // dataOutputStream.write(size);
149 | // dataOutputStream.write(byteArrayOutputStream.toByteArray());
150 | // dataOutputStream.flush();
151 | //// }else {
152 | ////
153 | //// }
154 | if (isImageChoose) {
155 | dataOutputStream.writeUTF(path.trim());
156 | dataOutputStream.flush();
157 | isImageChoose = false;
158 | } else {
159 | dataOutputStream.writeUTF(lblClient.getText() + " : " + txtMessage.getText().trim());
160 | dataOutputStream.flush();
161 | }
162 | txtMessage.clear();
163 | }
164 |
165 | public void btnImageChooserOnAction(MouseEvent actionEvent) throws IOException {
166 | // get the file selected
167 | FileChooser chooser = new FileChooser();
168 | Stage stage = new Stage();
169 | file = chooser.showOpenDialog(stage);
170 |
171 | if (file != null) {
172 | // dataOutputStream.writeUTF(file.getPath());
173 | path = file.getPath();
174 | System.out.println("selected");
175 | System.out.println(file.getPath());
176 | isImageChoose = true;
177 | }
178 | }
179 |
180 | public void btnExitOnAction(MouseEvent actionEvent) throws IOException {
181 | if (socket != null) {
182 | dataOutputStream.writeUTF("exit".trim());
183 | dataOutputStream.flush();
184 | System.exit(0);
185 | }
186 | System.exit(0);
187 | }
188 |
189 | public void btnEmojiOnAction(MouseEvent mouseEvent) {
190 | if (isUsed) {
191 | emoji.getChildren().clear();
192 | isUsed = false;
193 | return;
194 | }
195 | isUsed = true;
196 | VBox dialogVbox = new VBox(20);
197 | ImageView smile = new ImageView(new Image("lk/play_tech/chat_application/assets/smile.png"));
198 | smile.setFitWidth(30);
199 | smile.setFitHeight(30);
200 | dialogVbox.getChildren().add(smile);
201 | ImageView heart = new ImageView(new Image("lk/play_tech/chat_application/assets/heart.png"));
202 | heart.setFitWidth(30);
203 | heart.setFitHeight(30);
204 | dialogVbox.getChildren().add(heart);
205 | ImageView sadFace = new ImageView(new Image("lk/play_tech/chat_application/assets/sad-face.png"));
206 | sadFace.setFitWidth(30);
207 | sadFace.setFitHeight(30);
208 | dialogVbox.getChildren().add(sadFace);
209 | smile.setOnMouseClicked(event -> {
210 | txtMessage.setText(txtMessage.getText() + "☺");
211 | });
212 | heart.setOnMouseClicked(event -> {
213 | txtMessage.setText(txtMessage.getText() + "♥");
214 | });
215 | sadFace.setOnMouseClicked(event -> {
216 | txtMessage.setText(txtMessage.getText() + "☹");
217 | });
218 | emoji.getChildren().add(dialogVbox);
219 | }
220 | }
221 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/Client02FormController.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.application.Platform;
4 | import javafx.embed.swing.SwingFXUtils;
5 | import javafx.event.ActionEvent;
6 | import javafx.scene.control.Label;
7 | import javafx.scene.control.ScrollPane;
8 | import javafx.scene.control.TextField;
9 | import javafx.scene.image.Image;
10 | import javafx.scene.image.ImageView;
11 | import javafx.scene.input.MouseEvent;
12 | import javafx.scene.layout.AnchorPane;
13 | import javafx.scene.layout.VBox;
14 | import javafx.stage.FileChooser;
15 | import javafx.stage.Stage;
16 |
17 | import javax.imageio.ImageIO;
18 | import java.awt.image.BufferedImage;
19 | import java.io.*;
20 | import java.net.Socket;
21 |
22 | public class Client02FormController {
23 | public ScrollPane msgContext;
24 | public TextField txtMessage;
25 | public AnchorPane context = new AnchorPane();
26 |
27 | final int PORT = 60000;
28 | public Label lblClient;
29 | public AnchorPane emoji;
30 | Socket socket;
31 | Socket imgSocket;
32 | DataInputStream dataInputStream;
33 | DataOutputStream dataOutputStream;
34 | String message = "";
35 | int i = 10;
36 | String path = "";
37 | public static boolean isImageChoose = false;
38 | ObjectOutputStream oos;
39 | ObjectInputStream ois;
40 | File file;
41 | OutputStream imgOutputStream;
42 | InputStream imgInputStream;
43 | public static String name;
44 | boolean isUsed = false;
45 |
46 | public void initialize() {
47 | Platform.setImplicitExit(false);
48 | msgContext.setContent(context);
49 | msgContext.vvalueProperty().bind(context.heightProperty());
50 | msgContext.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
51 | msgContext.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
52 | lblClient.setText(LoginForm02Controller.name);
53 | name = lblClient.getText();
54 |
55 | new Thread(() -> {
56 | try {
57 | socket = new Socket("localhost", PORT);
58 |
59 | while (true) {
60 | dataOutputStream = new DataOutputStream(socket.getOutputStream());
61 | dataInputStream = new DataInputStream(socket.getInputStream());
62 | message = dataInputStream.readUTF();
63 | System.out.println(message);
64 |
65 | Platform.runLater(new Runnable() {
66 | @Override
67 | public void run() {
68 | if (message.startsWith("/")) {
69 | BufferedImage sendImage = null;
70 | try {
71 | sendImage = ImageIO.read(new File(message));
72 | } catch (IOException e) {
73 | e.printStackTrace();
74 | }
75 | Image img = SwingFXUtils.toFXImage(sendImage, null);
76 | ImageView imageView = new ImageView(img);
77 | imageView.setFitHeight(150);
78 | imageView.setFitWidth(150);
79 | imageView.setLayoutY(i);
80 | context.getChildren().add(imageView);
81 | i += 150;
82 | } else if (message.startsWith(LoginForm02Controller.name)) {
83 | message = message.replace(LoginForm02Controller.name, "You");
84 | Label label = new Label(message);
85 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #85b6ff; -fx-text-fill: #5c5c5c");
86 | label.setLayoutY(i);
87 | context.getChildren().add(label);
88 | } else {
89 | Label label = new Label(message);
90 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #CDB4DB; -fx-text-fill: #5c5c5c");
91 | label.setLayoutY(i);
92 | context.getChildren().add(label);
93 | }
94 | i += 30;
95 | }
96 | });
97 | }
98 | } catch (IOException e) {
99 | e.printStackTrace();
100 | }
101 | }).start();
102 |
103 | // new Thread(() -> {
104 | // try {
105 | // imgSocket = new Socket("localhost", PORT + 1);
106 | // while (true) {
107 | // imgOutputStream = imgSocket.getOutputStream();
108 | // imgInputStream = imgSocket.getInputStream();
109 | // byte[] sizeAr = new byte[4];
110 | // imgInputStream.read(sizeAr);
111 | // int size = ByteBuffer.wrap(sizeAr).asIntBuffer().get();
112 | //
113 | // byte[] imageAr = new byte[size];
114 | // imgInputStream.read(imageAr);
115 | //
116 | // BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageAr));
117 | //
118 | // System.out.println("Received " + image.getHeight() + "x" + image.getWidth() + ": " + System.currentTimeMillis());
119 | // ImageIO.write(image, "jpg", new File("/media/sandu/0559F5C021740317/GDSE/Project_Zone/IdeaProjects/INP_Course_Work/src/lk/play_tech/chat_application/bo/test2.jpg"));
120 | // //BufferedImage sendImage = ImageIO.read(new File("/home/sandu/Downloads/296351115_1695464754171592_2138034279597586981_n.jpg"));
121 | //
122 | // Platform.runLater(new Runnable() {
123 | // @Override
124 | // public void run() {
125 | // Image img = SwingFXUtils.toFXImage(image, null);
126 | // ImageView imageView = new ImageView(img);
127 | // imageView.setFitHeight(150);
128 | // imageView.setFitWidth(150);
129 | // imageView.setLayoutY(100);
130 | // context.getChildren().add(imageView);
131 | // i += 120;
132 | // }
133 | // });
134 | // }
135 | //
136 | // } catch (IOException e) {
137 | // e.printStackTrace();
138 | // }
139 | // }).start();
140 | }
141 |
142 | public void btnSendOnAction(MouseEvent actionEvent) throws IOException {
143 | //// if (isImageChoose){
144 | // BufferedImage image = ImageIO.read(new File(path));
145 | //
146 | // ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
147 | // ImageIO.write(image, "png", byteArrayOutputStream);
148 | //
149 | // byte[] size = ByteBuffer.allocate(4).putInt(byteArrayOutputStream.size()).array();
150 | // dataOutputStream.write(size);
151 | // dataOutputStream.write(byteArrayOutputStream.toByteArray());
152 | // dataOutputStream.flush();
153 | //// }else {
154 | ////
155 | //// }
156 | if (isImageChoose) {
157 | dataOutputStream.writeUTF(path.trim());
158 | dataOutputStream.flush();
159 | isImageChoose = false;
160 | } else {
161 | dataOutputStream.writeUTF(lblClient.getText() + " : " + txtMessage.getText().trim());
162 | dataOutputStream.flush();
163 | }
164 | txtMessage.clear();
165 | }
166 |
167 | public void btnImageChooserOnAction(MouseEvent actionEvent) throws IOException {
168 | // get the file selected
169 | FileChooser chooser = new FileChooser();
170 | Stage stage = new Stage();
171 | file = chooser.showOpenDialog(stage);
172 |
173 | if (file != null) {
174 | // dataOutputStream.writeUTF(file.getPath());
175 | path = file.getPath();
176 | System.out.println("selected");
177 | System.out.println(file.getPath());
178 | isImageChoose = true;
179 | }
180 | }
181 |
182 | public void btnExitOnAction(MouseEvent actionEvent) throws IOException {
183 | if (socket != null) {
184 | dataOutputStream.writeUTF("exit".trim());
185 | dataOutputStream.flush();
186 | System.exit(0);
187 | }
188 | System.exit(0);
189 | }
190 |
191 | public void btnEmojiOnAction(MouseEvent mouseEvent) {
192 | if (isUsed) {
193 | emoji.getChildren().clear();
194 | isUsed = false;
195 | return;
196 | }
197 | isUsed = true;
198 | VBox dialogVbox = new VBox(20);
199 | ImageView smile = new ImageView(new Image("lk/play_tech/chat_application/assets/smile.png"));
200 | smile.setFitWidth(30);
201 | smile.setFitHeight(30);
202 | dialogVbox.getChildren().add(smile);
203 | ImageView heart = new ImageView(new Image("lk/play_tech/chat_application/assets/heart.png"));
204 | heart.setFitWidth(30);
205 | heart.setFitHeight(30);
206 | dialogVbox.getChildren().add(heart);
207 | ImageView sadFace = new ImageView(new Image("lk/play_tech/chat_application/assets/sad-face.png"));
208 | sadFace.setFitWidth(30);
209 | sadFace.setFitHeight(30);
210 | dialogVbox.getChildren().add(sadFace);
211 | smile.setOnMouseClicked(event -> {
212 | txtMessage.setText(txtMessage.getText() + "☺");
213 | });
214 | heart.setOnMouseClicked(event -> {
215 | txtMessage.setText(txtMessage.getText() + "♥");
216 | });
217 | sadFace.setOnMouseClicked(event -> {
218 | txtMessage.setText(txtMessage.getText() + "☹");
219 | });
220 | emoji.getChildren().add(dialogVbox);
221 | }
222 | }
223 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/Client01FormController.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.application.Platform;
4 | import javafx.embed.swing.SwingFXUtils;
5 | import javafx.event.ActionEvent;
6 | import javafx.event.Event;
7 | import javafx.scene.control.Label;
8 | import javafx.scene.control.ScrollPane;
9 | import javafx.scene.control.TextField;
10 | import javafx.scene.image.Image;
11 | import javafx.scene.image.ImageView;
12 | import javafx.scene.input.MouseEvent;
13 | import javafx.scene.layout.AnchorPane;
14 | import javafx.scene.layout.VBox;
15 | import javafx.stage.FileChooser;
16 | import javafx.stage.Stage;
17 |
18 | import javax.imageio.ImageIO;
19 | import javax.imageio.stream.ImageInputStream;
20 | import javax.imageio.stream.ImageOutputStream;
21 | import java.awt.image.BufferedImage;
22 | import java.io.*;
23 | import java.net.Socket;
24 | import java.nio.ByteBuffer;
25 | import java.nio.charset.StandardCharsets;
26 |
27 | public class Client01FormController {
28 | public ScrollPane msgContext;
29 | public TextField txtMessage;
30 | public AnchorPane context = new AnchorPane();
31 |
32 | final int PORT = 50000;
33 | public Label lblClient;
34 | public AnchorPane emoji;
35 | Socket socket;
36 | Socket imgSocket;
37 | DataInputStream dataInputStream;
38 | DataOutputStream dataOutputStream;
39 | String message = "";
40 | int i = 10;
41 | String path = "";
42 | public static boolean isImageChoose = false;
43 | ObjectOutputStream oos;
44 | ObjectInputStream ois;
45 | File file;
46 | OutputStream imgOutputStream;
47 | InputStream imgInputStream;
48 | boolean isUsed = false;
49 |
50 | public void initialize() {
51 | Platform.setImplicitExit(false);
52 | msgContext.setContent(context);
53 | msgContext.vvalueProperty().bind(context.heightProperty());
54 | msgContext.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
55 | msgContext.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
56 | lblClient.setText(LoginForm01Controller.name);
57 |
58 | new Thread(() -> {
59 | try {
60 | socket = new Socket("localhost", PORT);
61 | while (true) {
62 | dataOutputStream = new DataOutputStream(socket.getOutputStream());
63 | dataInputStream = new DataInputStream(socket.getInputStream());
64 | message = dataInputStream.readUTF();
65 | System.out.println(message);
66 |
67 | Platform.runLater(new Runnable() {
68 | @Override
69 | public void run() {
70 | if (message.startsWith("/")) {
71 | BufferedImage sendImage = null;
72 | try {
73 | sendImage = ImageIO.read(new File(message));
74 | } catch (IOException e) {
75 | e.printStackTrace();
76 | }
77 | Image img = SwingFXUtils.toFXImage(sendImage, null);
78 | ImageView imageView = new ImageView(img);
79 | imageView.setFitHeight(150);
80 | imageView.setFitWidth(150);
81 | imageView.setLayoutY(i);
82 | context.getChildren().add(imageView);
83 | i += 150;
84 | } else if (message.startsWith(LoginForm01Controller.name)) {
85 | message = message.replace(LoginForm01Controller.name, "You");
86 | Label label = new Label(message);
87 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #85b6ff; -fx-text-fill: #5c5c5c");
88 | label.setLayoutY(i);
89 | context.getChildren().add(label);
90 | } else {
91 | Label label = new Label(message);
92 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #CDB4DB; -fx-text-fill: #5c5c5c");
93 | label.setLayoutY(i);
94 | context.getChildren().add(label);
95 | }
96 | i += 30;
97 | }
98 | });
99 | }
100 | } catch (IOException e) {
101 | e.printStackTrace();
102 | }
103 | }).start();
104 |
105 | txtMessage.setOnAction(event -> {
106 | try {
107 | sendMessage();
108 | } catch (IOException e) {
109 | e.printStackTrace();
110 | }
111 | });
112 |
113 | // new Thread(() -> {
114 | // try {
115 | // imgSocket = new Socket("localhost", PORT + 5);
116 | // while (true) {
117 | // imgOutputStream = imgSocket.getOutputStream();
118 | // imgInputStream = imgSocket.getInputStream();
119 | //
120 | // byte[] sizeAr = new byte[4];
121 | // imgInputStream.read(sizeAr);
122 | // int size = ByteBuffer.wrap(sizeAr).asIntBuffer().get();
123 | //
124 | // byte[] imageAr = new byte[size];
125 | // imgInputStream.read(imageAr);
126 | //
127 | // BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageAr));
128 | //
129 | // System.out.println("Received " + image.getHeight() + "x" + image.getWidth() + ": " + System.currentTimeMillis());
130 | // ImageIO.write(image, "jpg", new File("/media/sandu/0559F5C021740317/GDSE/Project_Zone/IdeaProjects/INP_Course_Work/src/lk/play_tech/chat_application/bo/test1.jpg"));
131 | // BufferedImage sendImage = ImageIO.read(new File("/media/sandu/0559F5C021740317/GDSE/Project_Zone/IdeaProjects/INP_Course_Work/src/lk/play_tech/chat_application/bo/test1.jpg"));
132 | //
133 | // Platform.runLater(new Runnable() {
134 | // @Override
135 | // public void run() {
136 | // Image img = SwingFXUtils.toFXImage(sendImage, null);
137 | // ImageView imageView = new ImageView(img);
138 | // imageView.setFitHeight(150);
139 | // imageView.setFitWidth(150);
140 | // imageView.setLayoutY(100);
141 | // context.getChildren().add(imageView);
142 | // i += 120;
143 | // }
144 | // });
145 | // }
146 | //
147 | // } catch (IOException e) {
148 | // e.printStackTrace();
149 | // }
150 | // }).start();
151 | }
152 |
153 | public void btnSendOnAction(MouseEvent actionEvent) throws IOException {
154 | //// if (isImageChoose){
155 | // BufferedImage image = ImageIO.read(new File(path));
156 | //
157 | // ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
158 | // ImageIO.write(image, "png", byteArrayOutputStream);
159 | //
160 | // byte[] size = ByteBuffer.allocate(4).putInt(byteArrayOutputStream.size()).array();
161 | // dataOutputStream.write(size);
162 | // dataOutputStream.write(byteArrayOutputStream.toByteArray());
163 | // dataOutputStream.flush();
164 | //// }else {
165 | ////
166 | //// }
167 | sendMessage();
168 | }
169 |
170 | private void sendMessage() throws IOException {
171 | if (isImageChoose) {
172 | dataOutputStream.writeUTF(path.trim());
173 | dataOutputStream.flush();
174 | isImageChoose = false;
175 | } else {
176 | dataOutputStream.writeUTF(lblClient.getText() + " : " + txtMessage.getText().trim());
177 | dataOutputStream.flush();
178 | }
179 | txtMessage.clear();
180 | }
181 |
182 | public void btnImageChooserOnAction(MouseEvent actionEvent) throws IOException {
183 | // get the file selected
184 | FileChooser chooser = new FileChooser();
185 | Stage stage = new Stage();
186 | file = chooser.showOpenDialog(stage);
187 |
188 | if (file != null) {
189 | // dataOutputStream.writeUTF(file.getPath());
190 | path = file.getPath();
191 | System.out.println("selected");
192 | System.out.println(file.getPath());
193 | isImageChoose = true;
194 | }
195 | }
196 |
197 | public void btnExitOnAction(MouseEvent actionEvent) throws IOException {
198 | if (socket != null) {
199 | dataOutputStream.writeUTF("exit".trim());
200 | dataOutputStream.flush();
201 | System.exit(0);
202 | }
203 | System.exit(0);
204 | }
205 |
206 | public void btnEmojiOnAction(MouseEvent mouseEvent) {
207 | if (isUsed) {
208 | emoji.getChildren().clear();
209 | isUsed = false;
210 | return;
211 | }
212 | isUsed = true;
213 | VBox dialogVbox = new VBox(20);
214 | ImageView smile = new ImageView(new Image("lk/play_tech/chat_application/assets/smile.png"));
215 | smile.setFitWidth(30);
216 | smile.setFitHeight(30);
217 | dialogVbox.getChildren().add(smile);
218 | ImageView heart = new ImageView(new Image("lk/play_tech/chat_application/assets/heart.png"));
219 | heart.setFitWidth(30);
220 | heart.setFitHeight(30);
221 | dialogVbox.getChildren().add(heart);
222 | ImageView sadFace = new ImageView(new Image("lk/play_tech/chat_application/assets/sad-face.png"));
223 | sadFace.setFitWidth(30);
224 | sadFace.setFitHeight(30);
225 | dialogVbox.getChildren().add(sadFace);
226 | smile.setOnMouseClicked(event -> {
227 | txtMessage.setText(txtMessage.getText() + "☺");
228 | });
229 | heart.setOnMouseClicked(event -> {
230 | txtMessage.setText(txtMessage.getText() + "♥");
231 | });
232 | sadFace.setOnMouseClicked(event -> {
233 | txtMessage.setText(txtMessage.getText() + "☹");
234 | });
235 | emoji.getChildren().add(dialogVbox);
236 | }
237 | }
238 |
--------------------------------------------------------------------------------
/src/lk/play_tech/chat_application/controller/ServerFormController.java:
--------------------------------------------------------------------------------
1 | package lk.play_tech.chat_application.controller;
2 |
3 | import javafx.application.Platform;
4 | import javafx.embed.swing.SwingFXUtils;
5 | import javafx.scene.control.Label;
6 | import javafx.scene.control.ScrollPane;
7 | import javafx.scene.control.TextField;
8 | import javafx.scene.image.Image;
9 | import javafx.scene.image.ImageView;
10 | import javafx.scene.input.MouseEvent;
11 | import javafx.scene.layout.AnchorPane;
12 | import javafx.scene.layout.VBox;
13 | import javafx.stage.FileChooser;
14 | import javafx.stage.Stage;
15 | import lk.play_tech.chat_application.model.Client;
16 |
17 | import javax.imageio.ImageIO;
18 | import javax.imageio.stream.ImageInputStream;
19 | import javax.imageio.stream.ImageOutputStream;
20 | import java.awt.image.BufferedImage;
21 | import java.io.*;
22 | import java.net.Socket;
23 | import java.nio.ByteBuffer;
24 |
25 | public class ServerFormController {
26 | public ScrollPane msgContext;
27 | public TextField txtMessage;
28 |
29 | final int PORT = 64000;
30 | final static int PORT1 = 50000;
31 | final int PORT2 = 60000;
32 | final int PORT3 = 65000;
33 | public AnchorPane emoji;
34 | Socket socket;
35 | DataInputStream dataInputStream0;
36 | DataOutputStream dataOutputStream0;
37 | ImageInputStream imgInputStream;
38 | ImageOutputStream imgOutputStream;
39 | String message = "";
40 | int i = 0;
41 | public AnchorPane context = new AnchorPane();
42 | Client serverClient;
43 | Client client;
44 | Client client2;
45 | Client client3;
46 | boolean isUsed = false;
47 | boolean isImageChoose = false;
48 | String path = "";
49 | // https://www.codegrepper.com/code-examples/java/java+send+an+image+over+a+socket
50 |
51 | public void initialize() {
52 | Platform.setImplicitExit(false);
53 | msgContext.setContent(context);
54 | msgContext.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
55 | msgContext.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
56 | msgContext.vvalueProperty().bind(context.heightProperty());
57 |
58 | // new Thread(() -> {
59 | // try {
60 | // Socket imgSocket = new Socket("localhost", PORT + 1);
61 | // while (true) {
62 | // imgOutputStream = imgSocket.getOutputStream();
63 | // imgInputStream = imgSocket.getInputStream();
64 | //
65 | // byte[] sizeAr = new byte[4];
66 | // imgInputStream.read(sizeAr);
67 | // int size = ByteBuffer.wrap(sizeAr).asIntBuffer().get();
68 | //
69 | // byte[] imageAr = new byte[size];
70 | // imgInputStream.read(imageAr);
71 | //
72 | // BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageAr));
73 | //
74 | // System.out.println("Received " + image.getHeight() + "x" + image.getWidth() + ": " + System.currentTimeMillis());
75 | // ImageIO.write(image, "jpg", new File("/media/sandu/0559F5C021740317/GDSE/Project_Zone/IdeaProjects/INP_Course_Work/src/lk/play_tech/chat_application/bo/test4.jpg"));
76 | // //BufferedImage sendImage = ImageIO.read(new File("/home/sandu/Downloads/296351115_1695464754171592_2138034279597586981_n.jpg"));
77 | //
78 | // Platform.runLater(new Runnable() {
79 | // @Override
80 | // public void run() {
81 | // Image img = SwingFXUtils.toFXImage(image, null);
82 | // ImageView imageView = new ImageView(img);
83 | // imageView.setFitHeight(150);
84 | // imageView.setFitWidth(150);
85 | // imageView.setLayoutY(100);
86 | // context.getChildren().add(imageView);
87 | // i += 120;
88 | // }
89 | // });
90 | // }
91 | // } catch (IOException e) {
92 | // e.printStackTrace();
93 | // }
94 | // }).start();
95 | new Thread(() -> {
96 | while (true) {
97 | serverClient = new Client(PORT);
98 | try {
99 | serverClient.setName("You ");
100 | serverClient.acceptConnection();
101 | serverClient.setInputAndOutput();
102 | processTextMessage(serverClient, serverClient.getDataInputStream());
103 | client = null;
104 | } catch (IOException e) {
105 | e.printStackTrace();
106 | }
107 | }
108 | }).start();
109 | new Thread(() -> {
110 | while (true) {
111 | try {
112 | client = new Client(PORT1);
113 | client.setName("Client 01");
114 | client.acceptConnection();
115 | client.setInputAndOutput();
116 | processTextMessage(client, client.getDataInputStream());
117 | } catch (IOException ignored) {
118 | }
119 | }
120 | }).start();
121 | new Thread(() -> {
122 | while (true) {
123 | client2 = new Client(PORT2);
124 | try {
125 | client2.setName("Client 02");
126 | client2.acceptConnection();
127 | client2.setInputAndOutput();
128 | processTextMessage(client2, client2.getDataInputStream());
129 | } catch (IOException ignored) {
130 | }
131 | }
132 | }).start();
133 | new Thread(() -> {
134 | while (true) {
135 | client3 = new Client(PORT3);
136 | try {
137 | client3.setName("Client 03");
138 | client3.acceptConnection();
139 | client3.setInputAndOutput();
140 | processTextMessage(client3, client3.getDataInputStream());
141 | } catch (IOException ignored) {
142 | }
143 | }
144 | }).start();
145 | // new Thread(() -> {
146 | // try {
147 | // serverClient.acceptImgConnection(PORT + 5);
148 | // serverClient.setImageInputAndOutput();
149 | // processImage(serverClient.getImgInputStream());
150 | // } catch (IOException e) {
151 | // e.printStackTrace();
152 | // }
153 | // }).start();
154 | // new Thread(() -> {
155 | // try {
156 | // client.acceptImgConnection(PORT1 + 5);
157 | // client.setImageInputAndOutput();
158 | // processImage(client.getImgInputStream());
159 | // } catch (IOException e) {
160 | // e.printStackTrace();
161 | // }
162 | // }).start();
163 | // new Thread(() -> {
164 | // try {
165 | // client2.acceptImgConnection(PORT2 + 1);
166 | // client2.setImageInputAndOutput();
167 | // processImage(client2.getImgInputStream());
168 | // } catch (IOException e) {
169 | // e.printStackTrace();
170 | // }
171 | // }).start();
172 | // new Thread(() -> {
173 | // try {
174 | // client3.acceptImgConnection(PORT3 + 1);
175 | // client3.setImageInputAndOutput();
176 | // processImage(client3.getImgInputStream());
177 | // } catch (IOException e) {
178 | // e.printStackTrace();
179 | // }
180 | // }).start();
181 | new Thread(() -> {
182 | try {
183 | socket = new Socket("localhost", PORT);
184 | Platform.runLater(new Runnable() {
185 | @Override
186 | public void run() {
187 | Label label = new Label("Server Started...");
188 | label.setStyle("-fx-font-family: Ubuntu; -fx-font-size: 20px;");
189 | label.setLayoutY(i);
190 | context.getChildren().add(label);
191 | i += 30;
192 | }
193 | });
194 | while (true) {
195 | dataOutputStream0 = new DataOutputStream(socket.getOutputStream());
196 | dataInputStream0 = new DataInputStream(socket.getInputStream());
197 | message = dataInputStream0.readUTF();
198 | System.out.println(message);
199 | Platform.runLater(new Runnable() {
200 | @Override
201 | public void run() {
202 | if (message.startsWith("/")) {
203 | BufferedImage sendImage = null;
204 | try {
205 | sendImage = ImageIO.read(new File(message));
206 | } catch (IOException e) {
207 | e.printStackTrace();
208 | }
209 | Image img = SwingFXUtils.toFXImage(sendImage, null);
210 | ImageView imageView = new ImageView(img);
211 | imageView.setFitHeight(150);
212 | imageView.setFitWidth(150);
213 | imageView.setLayoutY(i);
214 | context.getChildren().add(imageView);
215 | i += 150;
216 | }else if (message.startsWith("Admin")) {
217 | message = message.replace("Admin", "You");
218 | Label label = new Label(message);
219 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #85b6ff; -fx-text-fill: #5c5c5c");
220 | label.setLayoutY(i);
221 | context.getChildren().add(label);
222 | } else {
223 | Label label = new Label(message);
224 | label.setStyle(" -fx-font-family: Ubuntu; -fx-font-size: 20px; -fx-background-color: #CDB4DB; -fx-text-fill: #5c5c5c");
225 | label.setLayoutY(i);
226 | context.getChildren().add(label);
227 | }
228 | i += 30;
229 | }
230 | });
231 | }
232 | } catch (IOException e) {
233 | e.printStackTrace();
234 | }
235 | }).start();
236 | }
237 |
238 | public void btnSendOnAction(MouseEvent actionEvent) throws IOException {
239 | if (isImageChoose){
240 | dataOutputStream0.writeUTF(path.trim());
241 | dataOutputStream0.flush();
242 | isImageChoose = false;
243 | }else {
244 | dataOutputStream0.writeUTF("Admin : " + txtMessage.getText().trim());
245 | dataOutputStream0.flush();
246 | }
247 | txtMessage.clear();
248 | }
249 |
250 | public void btnImageChooserOnAction(MouseEvent actionEvent) {
251 | FileChooser chooser = new FileChooser();
252 | Stage stage = new Stage();
253 | File file = chooser.showOpenDialog(stage);
254 |
255 | if (file != null) {
256 | // dataOutputStream.writeUTF(file.getPath());
257 | path = file.getPath();
258 | System.out.println("selected");
259 | System.out.println(file.getPath());
260 | isImageChoose = true;
261 | }
262 | }
263 |
264 | public void btnExitOnAction(MouseEvent actionEvent) throws IOException {
265 | message = "Server Offline";
266 | sendTextMessage(message);
267 | System.exit(0);
268 | }
269 |
270 | public void processTextMessage(Client client, DataInputStream dataInputStream) throws IOException {
271 | if (dataOutputStream0 != null) {
272 | dataOutputStream0.writeUTF("👋\t\t\t" + client.getName() + " Joined\t\t\t👋".trim());
273 | dataOutputStream0.flush();
274 | }
275 |
276 | while (true) {
277 | message = dataInputStream.readUTF();
278 | System.out.println(message);
279 | if (message.equals("exit")) {
280 | client.setAccept(null);
281 | client.setImgSocket(null);
282 | dataOutputStream0.writeUTF("👋\t\t\t" + client.getName() + " left\t\t\t👋".trim());
283 | dataOutputStream0.flush();
284 | client.setServerSocket(null);
285 | return;
286 | }
287 | sendTextMessage(message);
288 | }
289 | }
290 |
291 | private void sendTextMessage(String message) throws IOException {
292 | if (serverClient.getAccept() != null) {
293 | serverClient.getDataOutputStream().writeUTF(message.trim());
294 | serverClient.getDataOutputStream().flush();
295 | }
296 | if (client.getAccept() != null) {
297 | client.getDataOutputStream().writeUTF(message.trim());
298 | client.getDataOutputStream().flush();
299 | }
300 | if (client2.getAccept() != null) {
301 | client2.getDataOutputStream().writeUTF(message.trim());
302 | client2.getDataOutputStream().flush();
303 | }
304 | if (client3.getAccept() != null) {
305 | client3.getDataOutputStream().writeUTF(message.trim());
306 | client3.getDataOutputStream().flush();
307 | }
308 | }
309 |
310 | // private void processImage(InputStream inputStream) throws IOException {
311 | // System.out.println("come");
312 | //// BufferedImage sendImage = ImageIO.read(new File(path));
313 | //
314 | // ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
315 | // byte[] sendSize = ByteBuffer.allocate(4).putInt(byteArrayOutputStream.size()).array();
316 | // sendImgMessage(sendSize, byteArrayOutputStream);
317 | // System.out.println("Flushed: " + System.currentTimeMillis());
318 | // System.out.println("Closing: " + System.currentTimeMillis());
319 | //// sendTextMessage(path);
320 | // sendImgMessage(sendSize,byteArrayOutputStream);
321 | // }
322 |
323 | // private void sendImgMessage(byte[] sendSize, ByteArrayOutputStream byteArrayOutputStream) throws IOException {
324 | // if (serverClient.getImgSocket() != null) {
325 | // serverClient.getImgOutputStream().write(sendSize);
326 | // serverClient.getImgOutputStream().write(byteArrayOutputStream.toByteArray());
327 | // serverClient.getImgOutputStream().flush();
328 | // }
329 | // if (client.getImgSocket() != null) {
330 | // client.getImgOutputStream().write(sendSize);
331 | // client.getImgOutputStream().write(byteArrayOutputStream.toByteArray());
332 | // client.getImgOutputStream().flush();
333 | // System.out.println("done");
334 | // }
335 | // if (client2.getImgSocket() != null) {
336 | // client2.getImgOutputStream().write(sendSize);
337 | // client2.getImgOutputStream().write(byteArrayOutputStream.toByteArray());
338 | // client2.getImgOutputStream().flush();
339 | // }
340 | // if (client3.getImgSocket() != null) {
341 | // client3.getImgOutputStream().write(sendSize);
342 | // client3.getImgOutputStream().write(byteArrayOutputStream.toByteArray());
343 | // client3.getImgOutputStream().flush();
344 | // }
345 | // }
346 |
347 | public void btnEmojiOnAction(MouseEvent mouseEvent) {
348 | if (isUsed) {
349 | emoji.getChildren().clear();
350 | isUsed = false;
351 | return;
352 | }
353 | isUsed = true;
354 | VBox dialogVbox = new VBox(20);
355 | ImageView smile = new ImageView(new Image("lk/play_tech/chat_application/assets/smile.png"));
356 | smile.setFitWidth(30);
357 | smile.setFitHeight(30);
358 | dialogVbox.getChildren().add(smile);
359 | ImageView heart = new ImageView(new Image("lk/play_tech/chat_application/assets/heart.png"));
360 | heart.setFitWidth(30);
361 | heart.setFitHeight(30);
362 | dialogVbox.getChildren().add(heart);
363 | ImageView sadFace = new ImageView(new Image("lk/play_tech/chat_application/assets/sad-face.png"));
364 | sadFace.setFitWidth(30);
365 | sadFace.setFitHeight(30);
366 | dialogVbox.getChildren().add(sadFace);
367 | smile.setOnMouseClicked(event -> {
368 | txtMessage.setText(txtMessage.getText() + "☺");
369 | });
370 | heart.setOnMouseClicked(event -> {
371 | txtMessage.setText(txtMessage.getText() + "♥");
372 | });
373 | sadFace.setOnMouseClicked(event -> {
374 | txtMessage.setText(txtMessage.getText() + "☹");
375 | });
376 | emoji.getChildren().add(dialogVbox);
377 | }
378 | }
379 |
--------------------------------------------------------------------------------