{"id":15055858,"url":"https://github.com/dustinkredmond/fxalert","last_synced_at":"2026-03-12T23:31:00.629Z","repository":{"id":49863988,"uuid":"323727882","full_name":"dustinkredmond/FXAlert","owner":"dustinkredmond","description":"JavaFX Alerts made easy. Easily create alerts, notifications, input dialogs, and more...","archived":false,"fork":false,"pushed_at":"2024-05-07T13:24:14.000Z","size":197,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T03:54:30.833Z","etag":null,"topics":["dialogs","icons","javafx","javafx-alert","javafx-application","notifications"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dustinkredmond.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"dustinkredmond"}},"created_at":"2020-12-22T20:37:01.000Z","updated_at":"2024-05-28T13:07:11.000Z","dependencies_parsed_at":"2024-05-07T13:42:33.100Z","dependency_job_id":null,"html_url":"https://github.com/dustinkredmond/FXAlert","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinkredmond%2FFXAlert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinkredmond%2FFXAlert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinkredmond%2FFXAlert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinkredmond%2FFXAlert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dustinkredmond","download_url":"https://codeload.github.com/dustinkredmond/FXAlert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154999,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dialogs","icons","javafx","javafx-alert","javafx-application","notifications"],"created_at":"2024-09-24T21:46:44.854Z","updated_at":"2026-03-12T23:31:00.579Z","avatar_url":"https://github.com/dustinkredmond.png","language":"Java","funding_links":["https://github.com/sponsors/dustinkredmond"],"categories":[],"sub_categories":[],"readme":"## FXAlert\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.dustinredmond.fxalert/FXAlert.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.dustinredmond.fxalert%22%20AND%20a:%22FXAlert%22)\n\nFXAlert believes that dialogs should come easy. JavaFX Alerts can be slightly convoluted.\nFor example, if we want to add a custom icon to a JavaFX Alert, we must create this monster:\n\n`((Stage) this.alert.getDialogPane().getScene().getWindow()).getIcons().add(YOUR_IMAGE);`\n\nFXAlert makes showing/creating dialogs, getting user input, graphics, icons, and using\nJavaFX Alerts in general, a much smoother process.\n\n---\n\n### How to get FXAlert\n\nWe're on Maven Central. Use Maven or your favorite build tool.\n\nIn pom.xml\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.dustinredmond.fxalert\u003c/groupId\u003e\n  \u003cartifactId\u003eFXAlert\u003c/artifactId\u003e\n  \u003cversion\u003e3.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIn build.gradle\n```groovy\ncompile group: 'com.dustinredmond.fxalert', name: 'FXAlert', version: '3.1.0'\n```\n\n---\n\n### How does it work?\n\nFXAlert's API makes it easy to create different types of dialogs. We have several ways to do this.\nWe can use the static methods:\n\n - FXAlert.info()\n - FXAlert.error()\n - FXAlert.warning()\n - FXAlert.confirm()\n - FXAlert.exception()\n - FXAlert.input()\n - FXAlert.flash()\n - FXAlert.choose()\n \nThese methods return  a builder-style syntax.\nWe can chain method calls to get the behavior we need.\n\n```java\nFXAlert.info().withText(\"Hello, World!\").withTitleBarIcon(icon).show();\nFXAlert.info().withGraphic(myGraphic).withText(\"Test\").show();\n```\n\n---\n\n### Title/Header/Content texts\n\nWe can set various types of text with overloaded `withText(...)` methods.\n\n```java\nFXAlert.info().withText(\"Title text\", \"Header text\", \"Content text\").show();\nFXAlert.info().withText(\"Header text\", \"Content text\").show();\nFXAlert.info().withText(\"Content text\").show();\n```\n\nThis will produce an Alert of type info with the given texts:\n\n![withText](./img/withText.png)\n\n---\n\n### Brevity, please!\n\nIf long method chains aren't your thing, we've got you covered. You can also use static convenience\nmethods included in FXAlert. \n\n```java\nFXAlert.showInfo(\"I'm an info dialog!\");\n```\n\n![info](./img/info.png)\n\n```java\nFXAlert.showWarning(\"I'm a warning dialog!\");\n```\n\n![warning](./img/warning.png)\n\n```java\nFXAlert.showException(ex, \"I'm an exception dialog!\");\n```\n\n![exception](./img/exception.png) \n\nNote that each short-hand method, also has a builder form:\n```java\ntry {\n    DriverManager.getConnection(url);\n} catch (Exception e) {\n    FXAlert.exception(e).withTextFormat(\"Couldn't reach: %s\", url).show();\n}\n```\n\n---\n\n### How about confirmation dialogs, how do those work?\n\n```java\nOptional\u003cButtonType\u003e result = FXAlert.confirm().withText(\"Please confirm!\").showAndWait();\nresult.ifPresent(e -\u003e {\n // do something with our result here\n});\n\n// But, wait, I don't like Optionals.\n// You should, but fine, we have you covered....\n\nboolean okay = FXAlert.showConfirmed(\"Click Ok or Cancel.\");\nif (okay) {\n    // user clicked \"Ok\"\n} else {\n    // user cancelled or closed window\n}\n```\n\nThis will create an Alert like below:\n\n![confirm](./img/confirm.png)\n\n---\n\n### Input Dialogs\n\nOften times, users are asked to enter a single piece of information. \nThis was a really easy dialog to build in Swing, but don't fear!\nFXAlert has built-in functionality to retrieve input data. Use `FXAlert.input()`\n\n`FXAlert.input()` works just like the other methods except instead of \n`show()` or `showAndWait()` methods, there are specific methods for getting\na particular type of data.\n\n```java\nOptional\u003cString\u003e aString = FXAlert.input().withText(\"Enter a String:\").showAndWaitString();\nOptional\u003cDouble\u003e aDouble = FXAlert.input().withText(\"Enter a Double:\").showAndWaitDouble();\nOptional\u003cInteger\u003e anInt = FXAlert.input().withText(\"Enter an Integer:\").showAndWaitInteger();\n```\n\nAs well as returning `Optional` values, the underlying input dialog requires that\nusers enter the correct data type before submission and prevents entry of other data.\nThe allowed type is determined by the appropriate `showAndWaitXXX` method. This prevents runtime errors when trying to\nparse the inputs, and saves a developer from having to check the returned data is a valid String/Double/Integer.\n\n![input](./img/input.png)\n\n---\n\n### \"Flash\" notifications\n\nThese are notifications that cause a banner to be temporarily displayed in the lower-right corner of the screen.\nThe banner appears for a few seconds, then fades out of view.\n\nThese can be built and invoked like below:\n\n```java\nFXAlert.flash()\n    .withHeader(\"Some Header Text\")\n    .withContent(\"Some more detailed content text...\")\n    .show();\n```\n\nFlash notifications can display custom icons, but can also use the same bundled JavaFX\nicons that we see in `Alert`s. By default, the flash notification uses the `AlertType.INFORMATION`\nicon, but we can specify which we want to see by using one of the below.\n\n```java\nFXAlert.flash().error()    // AlertType.ERROR icon\nFXAlert.flash().warn()     // AlertType.WARNING icon\nFXAlert.flash().confirm()  // AlertType.CONFIRMATION icon\nFXAlert.flash().info()     // AlertType.INFORMATION icon (default)\n\nFXAlert.flash().withGraphic(someNodeHere) // Use a custom icon\n```\n\nWhile the Alert class's built-in icons are nice, in order to retrieve their icons, FXAlert must look them\nup by the appropriate CSS class. Since the JavaFX stylesheet could change in a future release. It's preferred\nthat a developer specify their own custom \"flash\" notification graphic.\n\nA `flash` notification:\n\n![flash](./img/flash.png)\n\n---\n\n### Choice Dialogs\n\nChoice dialogs present the user with a list of choices from which they must pick.\nThis is invoked by calling the `FXAlert.choose()` method.\n\n```java\nFXAlert.choose(\"Option 1\", \"Option 2\", \"Option 3\")\n        .withText(\"Pick one!\")\n        .showAndWait();\n```\n\n![choose](./img/choose.png)\n\n---\n\n### Documentation\n\nFXAlert is a really simple library; most methods simply wrap JavaFX Alerts. For this reason,\nno separate documentation will be maintained. If you want to get a look at what's going on behind\nthe scenes, check out the [AlertBuilder](./src/main/java/com/dustinredmond/fxalert/AlertBuilder.java)\nclass, most of the action happens there.\n\nEach public method has thorough Javadoc. Protected, package-private, and private methods should \nalso define a reasonable Javadoc if they're not straight-forward.\n\n---\n\n### Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md). I'm happy to have you contribute to FXAlert, but I have a few\nminor beliefs on how it should be done.\n\nIn summary of CONTRIBUTING.md:\n  - Write clean code\n  - Use Issues and Pull Requests properly\n  - Don't waste maintainers' time with small typo fixes, etc.\n  - If the existing code handles something in an opinionated way,\n    try to stick with that same convention.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustinkredmond%2Ffxalert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdustinkredmond%2Ffxalert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustinkredmond%2Ffxalert/lists"}