From e2b6ec84fdd353e8f01bfee3d0aad7695be98679 Mon Sep 17 00:00:00 2001 From: prakadesh Date: Thu, 26 Oct 2023 14:08:37 +0530 Subject: [PATCH] added a output window popup --- .../Graphical_User_Interface.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/enerymonitoring/tool/enerymonitoring/Graphical_User_Interface.java b/src/main/java/com/enerymonitoring/tool/enerymonitoring/Graphical_User_Interface.java index d6a9d08..794ca1b 100644 --- a/src/main/java/com/enerymonitoring/tool/enerymonitoring/Graphical_User_Interface.java +++ b/src/main/java/com/enerymonitoring/tool/enerymonitoring/Graphical_User_Interface.java @@ -550,15 +550,34 @@ buttonBox, errorLabel, createOutputTextArea(), hbox_gauge // Add a method to display the output in a new window or dialog - private TextArea createOutputTextArea() { + private VBox createOutputTextArea() { outputTextArea = new TextArea(); outputTextArea.setEditable(false); outputTextArea.setWrapText(true); - outputTextArea.setPrefRowCount(10); // Set the number of visible rows - return outputTextArea; + outputTextArea.setPrefRowCount(10);// Set the number of visible rows + Button openOutputWindowButton = new Button("Open Output Window"); + openOutputWindowButton.setOnAction(e -> openOutputWindow(outputTextArea)); + openOutputWindowButton.setVisible(false); + openOutputWindowButton.setManaged(false); + VBox vbox_outputtextarea = new VBox(10, openOutputWindowButton, outputTextArea); + return vbox_outputtextarea; } - // Method to display the output in the TextArea + private void openOutputWindow(TextArea outputTextArea) { + Stage outputStage = new Stage(); + outputStage.setTitle("Energy Monitoring Output"); + TextArea outputInWindow = new TextArea(outputTextArea.getText()); + outputInWindow.setEditable(false); + outputInWindow.setStyle(darkModeStyles); + outputInWindow.setWrapText(true); + + Scene outputScene = new Scene(new StackPane(outputInWindow), 800, 600); + + outputStage.setScene(outputScene); + outputStage.show(); + } + + // Method to display the output in the TextArea private void displayOutputInTextArea(String output) { outputTextArea.appendText("\nEnergy Monitoring Output:\n" + output); outputTextArea.positionCaret(outputTextArea.getText().length());