-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
davide
committed
Mar 12, 2024
1 parent
4555055
commit b6aba0e
Showing
6 changed files
with
257 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/team/elrant/bubbles/gui/ChatPageApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package team.elrant.bubbles.gui; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import java.io.IOException; | ||
|
||
public class ChatPageApplication extends Application { | ||
|
||
public static void main(String[] args) { | ||
launch(); | ||
} | ||
|
||
@Override | ||
public void start(@org.jetbrains.annotations.NotNull Stage primaryStage) throws IOException { | ||
FXMLLoader fxmlLoader = new FXMLLoader(ChatPageApplication.class.getResource("ChatView.fxml")); | ||
Scene scene = new Scene(fxmlLoader.load(),400,800); | ||
primaryStage.setTitle("Chat"); | ||
primaryStage.setScene(scene); | ||
primaryStage.centerOnScreen(); | ||
primaryStage.setResizable(false); | ||
primaryStage.show(); | ||
|
||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/team/elrant/bubbles/gui/ChatPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package team.elrant.bubbles.gui; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextArea; | ||
import team.elrant.bubbles.xmpp.ConnectedUser; | ||
import java.io.IOException; | ||
|
||
public class ChatPageController{ | ||
@FXML | ||
private TextArea chatTextArea; | ||
@FXML | ||
private TextArea messageTextArea; | ||
@FXML | ||
private Button sendButton; | ||
@FXML | ||
private Label failedLoginLabel; | ||
private ConnectedUser connectedUser; | ||
private String contactJid; | ||
private String password; | ||
|
||
public ChatPageController(ConnectedUser connectedUser,String contactJid,String password){ | ||
this.connectedUser = connectedUser; | ||
this.contactJid = contactJid; | ||
this.password = password; | ||
} | ||
|
||
@FXML | ||
protected void initialize(){ | ||
|
||
connectedUser.addIncomingMessageListener(); | ||
|
||
sendButton.setOnAction(actionEvent -> sendMessage()); | ||
} | ||
@FXML | ||
protected void sendMessage(){ | ||
try{ | ||
String message = messageTextArea.getText(); | ||
connectedUser.getSendMessage(contactJid,message); | ||
chatTextArea.appendText("Me: "+ message + "\n"); | ||
messageTextArea.clear(); | ||
} | ||
catch (Exception e){ | ||
failedLoginLabel.setVisible(true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
|
||
|
||
<AnchorPane xmlns="http://javafx.com/javafx" | ||
xmlns:fx="http://javafx.com/fxml" | ||
fx:controller="team.elrant.bubbles.gui.ChatPageController" | ||
prefHeight="400.0" prefWidth="600.0"> | ||
//Text Area for chat | ||
<TextArea fx:id="chatTextArea" prefWidth="400" prefHeight="600" editable="false"/> | ||
|
||
//Text Area for message | ||
<TextArea fx:id="messageTextArea" prefWidth="300" prefHeight="100" layoutY="600"/> | ||
|
||
//Button for message | ||
<Button fx:id="sendButton" text="Send" onAction="#sendMessage" layoutY="620" layoutX="320"/> | ||
|
||
//Label for error | ||
<Label fx:id="failedLoginLabel" text="Failed to send message!" visible="false" textFill="red" layoutX="320" layoutY="650"/> | ||
</AnchorPane> |