├── .idea
├── .gitignore
├── libraries
│ └── jfoenix_8_0_8.xml
├── misc.xml
├── modules.xml
├── uiDesigner.xml
└── vcs.xml
├── chat application.iml
├── out
└── production
│ ├── chat application
│ ├── Appinitilizer.class
│ ├── assests
│ │ ├── angree.png
│ │ ├── camera.png
│ │ ├── care.png
│ │ ├── emoji-love.png
│ │ ├── haha.png
│ │ ├── happy.png
│ │ ├── heart.png
│ │ ├── kiss1.png
│ │ ├── love.png
│ │ ├── mask.png
│ │ ├── pain.jpg
│ │ ├── profile.png
│ │ ├── smile.png
│ │ ├── wow.jpg
│ │ └── wow1.jpg
│ ├── controller
│ │ ├── ClientHandler.class
│ │ ├── ClientOneForm.class
│ │ ├── LoginForm.class
│ │ └── Server.class
│ ├── lib
│ │ └── jfoenix-8.0.8.jar
│ ├── style
│ │ └── style.css
│ └── view
│ │ ├── ClientOneForm.fxml
│ │ └── LoginForm.fxml
│ └── server
│ └── view
│ └── ServerForm.fxml
└── src
├── Appinitilizer.java
├── assests
├── angree.png
├── camera.png
├── care.png
├── emoji-love.png
├── haha.png
├── happy.png
├── heart.png
├── kiss1.png
├── love.png
├── mask.png
├── pain.jpg
├── profile.png
├── smile.png
├── wow.jpg
└── wow1.jpg
├── controller
├── ClientHandler.java
├── ClientOneForm.java
├── LoginForm.java
└── Server.java
├── lib
└── jfoenix-8.0.8.jar
├── style
└── style.css
└── view
├── ClientOneForm.fxml
└── LoginForm.fxml
/.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 |
--------------------------------------------------------------------------------
/.idea/libraries/jfoenix_8_0_8.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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chat application.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/out/production/chat application/Appinitilizer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/Appinitilizer.class
--------------------------------------------------------------------------------
/out/production/chat application/assests/angree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/angree.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/camera.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/care.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/care.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/emoji-love.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/emoji-love.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/haha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/haha.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/happy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/happy.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/heart.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/kiss1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/kiss1.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/love.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/love.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/mask.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/pain.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/pain.jpg
--------------------------------------------------------------------------------
/out/production/chat application/assests/profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/profile.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/smile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/smile.png
--------------------------------------------------------------------------------
/out/production/chat application/assests/wow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/wow.jpg
--------------------------------------------------------------------------------
/out/production/chat application/assests/wow1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/assests/wow1.jpg
--------------------------------------------------------------------------------
/out/production/chat application/controller/ClientHandler.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/controller/ClientHandler.class
--------------------------------------------------------------------------------
/out/production/chat application/controller/ClientOneForm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/controller/ClientOneForm.class
--------------------------------------------------------------------------------
/out/production/chat application/controller/LoginForm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/controller/LoginForm.class
--------------------------------------------------------------------------------
/out/production/chat application/controller/Server.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/controller/Server.class
--------------------------------------------------------------------------------
/out/production/chat application/lib/jfoenix-8.0.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/out/production/chat application/lib/jfoenix-8.0.8.jar
--------------------------------------------------------------------------------
/out/production/chat application/style/style.css:
--------------------------------------------------------------------------------
1 | .text-input{
2 | -fx-text-inner-color: white;
3 | }
--------------------------------------------------------------------------------
/out/production/chat application/view/ClientOneForm.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
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 |
--------------------------------------------------------------------------------
/out/production/chat application/view/LoginForm.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 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/out/production/server/view/ServerForm.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/Appinitilizer.java:
--------------------------------------------------------------------------------
1 | import javafx.application.Application;
2 | import javafx.fxml.FXMLLoader;
3 | import javafx.scene.Parent;
4 | import javafx.scene.Scene;
5 | import javafx.stage.Stage;
6 |
7 | import java.io.IOException;
8 |
9 | public class Appinitilizer extends Application {
10 |
11 | public static void main(String[] args) {
12 | launch(args);
13 | }
14 |
15 | @Override
16 | public void start(Stage primaryStage) throws IOException {
17 | Parent parent = FXMLLoader.load(this.getClass().getResource("/view/LoginForm.fxml"));
18 | Scene mainScene = new Scene(parent);
19 | primaryStage.setTitle("Live Chat");
20 | primaryStage.setScene(mainScene);
21 | primaryStage.centerOnScreen();
22 | primaryStage.show();
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/assests/angree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/angree.png
--------------------------------------------------------------------------------
/src/assests/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/camera.png
--------------------------------------------------------------------------------
/src/assests/care.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/care.png
--------------------------------------------------------------------------------
/src/assests/emoji-love.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/emoji-love.png
--------------------------------------------------------------------------------
/src/assests/haha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/haha.png
--------------------------------------------------------------------------------
/src/assests/happy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/happy.png
--------------------------------------------------------------------------------
/src/assests/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/heart.png
--------------------------------------------------------------------------------
/src/assests/kiss1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/kiss1.png
--------------------------------------------------------------------------------
/src/assests/love.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/love.png
--------------------------------------------------------------------------------
/src/assests/mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/mask.png
--------------------------------------------------------------------------------
/src/assests/pain.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/pain.jpg
--------------------------------------------------------------------------------
/src/assests/profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/profile.png
--------------------------------------------------------------------------------
/src/assests/smile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/smile.png
--------------------------------------------------------------------------------
/src/assests/wow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/wow.jpg
--------------------------------------------------------------------------------
/src/assests/wow1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/assests/wow1.jpg
--------------------------------------------------------------------------------
/src/controller/ClientHandler.java:
--------------------------------------------------------------------------------
1 | package controller;/*
2 | @author Dasun
3 | */
4 |
5 | import java.io.*;
6 | import java.net.Socket;
7 | import java.util.ArrayList;
8 |
9 | public class ClientHandler extends Thread {
10 |
11 | public static ArrayList clientHandlerArrayList;
12 | private Socket socket;
13 | private BufferedReader bufferedReader;
14 | private BufferedWriter bufferedWriter;
15 | private String clientUsername;
16 | private PrintWriter printWriter;
17 |
18 | public ClientHandler(Socket socket,ArrayListclientHandlers){
19 | try{
20 | this.socket = socket;
21 | this.clientHandlerArrayList =clientHandlers;
22 | this.bufferedReader= new BufferedReader(new InputStreamReader(socket.getInputStream()));
23 | this.printWriter=new PrintWriter(socket.getOutputStream(),true);
24 |
25 |
26 | }catch (IOException e){
27 | e.printStackTrace();
28 | }
29 | }
30 |
31 |
32 |
33 | public void run() {
34 |
35 | try{
36 | String massage;
37 | while ((massage = bufferedReader.readLine()) != null) {
38 | if(massage.equalsIgnoreCase("exit")) {
39 | break;
40 | }
41 |
42 | for(ClientHandler c : clientHandlerArrayList) {
43 | c.printWriter.println(massage);
44 | }
45 | }
46 | } catch (Exception e) {
47 | e.printStackTrace();
48 | }
49 |
50 | finally {
51 | try {
52 | bufferedReader.close();
53 | printWriter.close();
54 | socket.close();
55 | } catch (IOException e) {
56 | e.printStackTrace();
57 | }
58 | }
59 |
60 |
61 | }
62 |
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/controller/ClientOneForm.java:
--------------------------------------------------------------------------------
1 | package controller;/*
2 | @author Dasun
3 | */
4 |
5 | import com.jfoenix.controls.JFXTextField;
6 | import javafx.application.Platform;
7 | import javafx.event.ActionEvent;
8 | import javafx.geometry.Pos;
9 | import javafx.scene.Node;
10 | import javafx.scene.control.Label;
11 | import javafx.scene.image.Image;
12 | import javafx.scene.image.ImageView;
13 | import javafx.scene.input.MouseEvent;
14 | import javafx.scene.layout.HBox;
15 | import javafx.scene.layout.VBox;
16 | import javafx.scene.text.Text;
17 | import javafx.scene.text.TextFlow;
18 | import javafx.stage.FileChooser;
19 | import javafx.stage.Stage;
20 |
21 | import java.io.*;
22 | import java.net.Socket;
23 | import java.nio.charset.StandardCharsets;
24 |
25 | public class ClientOneForm extends Thread{
26 |
27 | public JFXTextField txtTextField;
28 | public VBox vBox;
29 | public ImageView imgSendImages;
30 | public Label lblUser;
31 | public FileChooser chooser;
32 | public File path;
33 | public ImageView imgSendImages1;
34 | private Socket socket;
35 | private BufferedReader bufferedReader;
36 | private BufferedWriter bufferedWriter;
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | private String username;
51 |
52 |
53 |
54 | private PrintWriter printWriter;
55 |
56 | public void initialize() throws IOException {
57 |
58 | String userName = LoginForm.userName;
59 | lblUser.setText(userName);
60 |
61 | try {
62 | socket = new Socket("localhost", 8000);
63 | bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
64 | printWriter = new PrintWriter(socket.getOutputStream(), true);
65 | this.start();
66 |
67 | } catch (IOException e) {
68 | e.printStackTrace();
69 | }
70 |
71 | }
72 |
73 | public void sendOnAction(ActionEvent actionEvent) {
74 | String massage = txtTextField.getText();
75 | printWriter.println(lblUser.getText() + ": " + massage);
76 | txtTextField.clear();
77 | printWriter.flush();
78 | if (massage.equalsIgnoreCase("exit")) {
79 | Stage stage = (Stage) txtTextField.getScene().getWindow();
80 |
81 |
82 | stage.close();
83 | }
84 |
85 | }
86 |
87 | public void sendImgClicked(MouseEvent mouseEvent) {
88 | Stage stage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow();
89 | chooser = new FileChooser();
90 | chooser.setTitle("Open Image");
91 | this.path = chooser.showOpenDialog(stage);
92 | printWriter.println(lblUser.getText() + " " + "img" + path.getPath());
93 | printWriter.flush();
94 |
95 |
96 | }
97 |
98 |
99 | public void run() {
100 | try {
101 | while (true) {
102 | String massage = bufferedReader.readLine();
103 | String[] tokens = massage.split(" ");
104 | String command = tokens[0];
105 |
106 | StringBuilder clientMassage = new StringBuilder();
107 | for (int i = 1; i < tokens.length; i++) {
108 | clientMassage.append(tokens[i] + " ");
109 | }
110 |
111 | String[] massageAr = massage.split(" ");
112 | String string = "";
113 | for (int i = 0; i < massageAr.length - 1; i++) {
114 | string += massageAr[i + 1] + " ";
115 | }
116 |
117 | Text text = new Text(string);
118 | String fChar = "";
119 |
120 | if (string.length() > 3) {
121 | fChar = string.substring(0, 3);
122 | }
123 |
124 | if (fChar.equalsIgnoreCase("img")) {
125 | string = string.substring(3, string.length() - 1);
126 |
127 | File file = new File(string);
128 | Image image = new Image(file.toURI().toString());
129 |
130 | ImageView imageView = new ImageView(image);
131 |
132 | imageView.setFitWidth(150);
133 | imageView.setFitHeight(200);
134 |
135 | HBox hBox = new HBox(10);
136 | hBox.setAlignment(Pos.BOTTOM_RIGHT);
137 |
138 | if (!command.equalsIgnoreCase(lblUser.getText())) {
139 | vBox.setAlignment(Pos.TOP_LEFT);
140 | hBox.setAlignment(Pos.CENTER_LEFT);
141 |
142 | Text text1 = new Text(" " + command + " :");
143 | hBox.getChildren().add(text1);
144 | hBox.getChildren().add(imageView);
145 | } else {
146 | hBox.setAlignment(Pos.BOTTOM_RIGHT);
147 | hBox.getChildren().add(imageView);
148 | Text text1 = new Text(": Me ");
149 | hBox.getChildren().add(text1);
150 | }
151 |
152 | Platform.runLater(() -> vBox.getChildren().addAll(hBox));
153 |
154 | } else {
155 | TextFlow tempTextFlow = new TextFlow();
156 |
157 | if (!command.equalsIgnoreCase(lblUser.getText() + ":")) {
158 | Text name = new Text(command + " ");
159 | name.getStyleClass().add("name");
160 | tempTextFlow.getChildren().add(name);
161 | }
162 |
163 | tempTextFlow.getChildren().add(text);
164 | tempTextFlow.setMaxWidth(200);
165 |
166 | TextFlow textFlow = new TextFlow(tempTextFlow);
167 | HBox hBox = new HBox(12);
168 |
169 | if (!command.equalsIgnoreCase(lblUser.getText() + ":")) {
170 | vBox.setAlignment(Pos.TOP_LEFT);
171 | hBox.setAlignment(Pos.CENTER_LEFT);
172 | hBox.getChildren().add(textFlow);
173 | } else {
174 | Text text1 = new Text(clientMassage + ": Me");
175 | TextFlow textFlow1 = new TextFlow(text1);
176 | hBox.setAlignment(Pos.BOTTOM_RIGHT);
177 | hBox.getChildren().add(textFlow1);
178 | }
179 | Platform.runLater(() -> vBox.getChildren().addAll(hBox));
180 | }
181 | }
182 | } catch (Exception e) {
183 | e.printStackTrace();
184 | }
185 | }
186 |
187 |
188 | public void mojOnAction(MouseEvent mouseEvent) {
189 | if (mouseEvent.getSource() instanceof ImageView) if (mouseEvent.getSource() instanceof ImageView) {
190 | ImageView icon = (ImageView) mouseEvent.getSource();
191 | switch (icon.getId()) {
192 | case "imgSendImages1":
193 | //heart
194 | byte[] byte1 = {(byte) 0xE2, (byte) 0x9D, (byte) 0xA4};
195 | String emoji1AsString = new String(byte1, StandardCharsets.UTF_8);
196 | txtTextField.appendText(emoji1AsString);
197 | break;
198 | }
199 | }
200 |
201 | }
202 |
203 |
204 |
205 |
206 |
207 | }
208 |
--------------------------------------------------------------------------------
/src/controller/LoginForm.java:
--------------------------------------------------------------------------------
1 | package controller;/*
2 | @author Dasun
3 | */
4 |
5 | import com.jfoenix.controls.JFXTextField;
6 | import javafx.event.ActionEvent;
7 | import javafx.fxml.FXMLLoader;
8 | import javafx.scene.Scene;
9 | import javafx.stage.Stage;
10 |
11 | import java.io.IOException;
12 |
13 | public class LoginForm {
14 | public JFXTextField txtUserName;
15 |
16 | public static String userName;
17 |
18 | public void btnLoginOnAction(ActionEvent actionEvent) throws IOException {
19 | userName =txtUserName.getText();
20 | Stage stage = (Stage) txtUserName.getScene().getWindow();
21 | stage.close();
22 | Stage stage1 = new Stage();
23 | stage1.setScene(new Scene(FXMLLoader.load(getClass().getResource("/view/ClientOneForm.fxml"))));
24 | stage1.setTitle("Online Chat ");
25 | stage1.setResizable(false);
26 | stage1.centerOnScreen();
27 | stage1.show();
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/controller/Server.java:
--------------------------------------------------------------------------------
1 | package controller;/*
2 | @author Dasun
3 | */
4 |
5 | import java.io.IOException;
6 | import java.net.ServerSocket;
7 | import java.net.Socket;
8 | import java.util.ArrayList;
9 |
10 | public class Server {
11 |
12 |
13 | private static ArrayList clientHandlerArray =new ArrayList<>();
14 |
15 |
16 |
17 | public static void main(String[] args) throws IOException {
18 | ServerSocket serverSocket = new ServerSocket(8000);
19 | Socket accept;
20 |
21 | while(true){
22 | System.out.println("Weiting for client");
23 | accept =serverSocket.accept();
24 | System.out.println("new member coNECTD");
25 | ClientHandler clientHandler=new ClientHandler(accept, clientHandlerArray);
26 | clientHandlerArray.add(clientHandler);
27 | clientHandler.start();
28 |
29 | }
30 |
31 |
32 |
33 | }
34 |
35 |
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/jfoenix-8.0.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dasunthamsh/group-chat-app-java/e8a589acfd6b801b994653b9d21256237d9e7d27/src/lib/jfoenix-8.0.8.jar
--------------------------------------------------------------------------------
/src/style/style.css:
--------------------------------------------------------------------------------
1 | .text-input{
2 | -fx-text-inner-color: white;
3 | }
--------------------------------------------------------------------------------
/src/view/ClientOneForm.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
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 |
--------------------------------------------------------------------------------
/src/view/LoginForm.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 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------