From fbfe0f07bce91bd697eceaa2d305ca139cfc4c23 Mon Sep 17 00:00:00 2001 From: Justin Kunimune Date: Thu, 14 Dec 2023 14:43:15 -0800 Subject: [PATCH] error messages that you can read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I discoverd that the error pane automaticly cuts off the last few words of your error message if it can fit *almost* the whole message on one line. god, javafx is stupid. I hacked at it until it wraps consistently so that *all* – not just *almost all* – of the words I ask it to show the user are actually shown to the user. --- src/apps/MapApplication.java | 9 ++++++++- src/apps/MapDesignerVector.java | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/apps/MapApplication.java b/src/apps/MapApplication.java index 090ab26..a4fe639 100644 --- a/src/apps/MapApplication.java +++ b/src/apps/MapApplication.java @@ -32,6 +32,7 @@ import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.concurrent.Task; +import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.Scene; @@ -56,6 +57,7 @@ import javafx.scene.input.KeyEvent; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; @@ -686,7 +688,12 @@ public abstract class MapApplication extends Application { protected static void showError(String header, String message) { //a simple error handling thing final Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(header); - alert.setContentText(message); + Text contentText = new Text(message); + contentText.setWrappingWidth(350); + StackPane contentPane = new StackPane(contentText); + contentPane.setPadding(new Insets(10, 10, 10, 10)); + contentPane.setAlignment(Pos.CENTER); + alert.getDialogPane().setContent(contentPane); alert.showAndWait(); } diff --git a/src/apps/MapDesignerVector.java b/src/apps/MapDesignerVector.java index 375640d..806a76b 100644 --- a/src/apps/MapDesignerVector.java +++ b/src/apps/MapDesignerVector.java @@ -142,13 +142,16 @@ public class MapDesignerVector extends MapApplication { protected void failed() { if (getException() instanceof IOException) showError("File not found!", - "We couldn't find "+file.getAbsolutePath()+"."); + "We couldn't find "+file.getAbsolutePath()+"."); else if (getException() instanceof SAXException) showError("Unreadable file!", - "We couldn't read "+file.getAbsolutePath()+". It may be corrupt or an unreadable format."); + "We couldn't read "+file.getAbsolutePath()+". It may be corrupt or an unreadable format. " + + "If you think your SVG file is valid, leave an issue on the GitHub (https://github.com/" + + "jkunimune/Map-Projections/issues) or send me an email (justin.kunimune@gmail.com) and " + + "I'll see if I can find out why this isn't working."); else if (getException() instanceof ParserConfigurationException) showError("Parser Configuration Error!", - "My parser configured incorrectly. I blame you."); + "My parser configured incorrectly. I blame you."); else { getException().printStackTrace(); showError("Unexpected error!", getException().getMessage());