Browse Source

Changed behavior of images slightly

cam
Thomas Johnson 3 years ago
parent
commit
c0c663f04b
  1. 16
      window/WindowProtoHandler.java

16
window/WindowProtoHandler.java

@ -57,23 +57,21 @@ public class WindowProtoHandler implements ProtoHandler {
@Override
public void handleFile(String username, String filename, byte[] data) {
if (filename.endsWith(".png") || filename.endsWith(".jpg")) {
Platform.runLater(() -> {
Image image = new Image(new ByteArrayInputStream(data));
chatWindow.addImage(username, image);
});
}
else {
Platform.runLater(() -> {
Platform.runLater(() -> {
{
try {
if (filename.endsWith(".png") || filename.endsWith(".jpg")) {
Image image = new Image(new ByteArrayInputStream(data));
chatWindow.addImage(username, image);
}
chatWindow.addMessage("Server", "User [" + username + "] has sent the file \"" + filename + "\".");
FileOutputStream fileOutputStream = new FileOutputStream(filename);
fileOutputStream.write(data);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
@Override

Loading…
Cancel
Save