|
9 | 9 | package Controller;
|
10 | 10 |
|
11 | 11 | import animatefx.animation.FadeIn;
|
| 12 | +import javafx.embed.swing.SwingFXUtils; |
12 | 13 | import javafx.event.ActionEvent;
|
13 | 14 | import javafx.fxml.Initializable;
|
14 | 15 | import javafx.geometry.NodeOrientation;
|
|
27 | 28 | import javafx.scene.shape.Rectangle;
|
28 | 29 | import javafx.stage.FileChooser;
|
29 | 30 |
|
| 31 | +import javax.imageio.ImageIO; |
| 32 | +import java.awt.image.BufferedImage; |
30 | 33 | import java.io.*;
|
31 | 34 | import java.net.Socket;
|
32 | 35 | import java.net.URL;
|
@@ -62,6 +65,11 @@ public class Client_Room extends Thread implements Initializable {
|
62 | 65 | public Rectangle emojiBox;
|
63 | 66 |
|
64 | 67 | public boolean toggleChat = false, toggleProfile = false;
|
| 68 | + |
| 69 | + /** Changing profile pic */ |
| 70 | + |
| 71 | + public boolean saveControl = false; |
| 72 | + |
65 | 73 | BufferedReader reader;
|
66 | 74 | PrintWriter writer;
|
67 | 75 | Socket socket;
|
@@ -177,6 +185,18 @@ public void chooseImageButton(ActionEvent event) {
|
177 | 185 | }
|
178 | 186 |
|
179 | 187 | public void saveImage(ActionEvent event) {
|
| 188 | + if (saveControl) { |
| 189 | + try { |
| 190 | + BufferedImage bufferedImage = ImageIO.read(filePath); |
| 191 | + Image image = SwingFXUtils.toFXImage(bufferedImage, null); |
| 192 | + proImage.setImage(image); |
| 193 | + showProPic.setFill(new ImagePattern(image)); |
| 194 | + saveControl = false; |
| 195 | + fileChoosePath.setText(""); |
| 196 | + } catch (IOException e) { |
| 197 | + System.err.println(e.getMessage()); |
| 198 | + } |
| 199 | + } |
180 | 200 | }
|
181 | 201 |
|
182 | 202 | public void mouseClickedAnotherArea(MouseEvent mouseEvent) {
|
|
0 commit comments