Skip to content

Commit

Permalink
Add image examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinkredmond committed Jun 9, 2021
1 parent a69ca3d commit 3cbe981
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 11 deletions.
68 changes: 57 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,57 @@ We can use the static methods:
- FXAlert.exception()
- FXAlert.input()
- FXAlert.flash()
- FXAlert.choose()

These methods return a builder-style syntax.
We can chain method calls to get the behavior we need.

`FXAlert.info().withText("Hello, World!").withTitleBarIcon(icon).show();`

`FXAlert.info().withGraphic(myGraphic).withText("Test").show();`
```java
FXAlert.info().withText("Hello, World!").withTitleBarIcon(icon).show();
FXAlert.info().withGraphic(myGraphic).withText("Test").show();
```

---

### Title/Header/Content texts

We can set various types of text with overloaded `withText(...)` methods.

```
FXAlert.info().withText("Title text", "Header text", "Content text");
FXAlert.info().withText("Header text", "Content text");
FXAlert.info().withText("Content text");
```java
FXAlert.info().withText("Title text", "Header text", "Content text").show();
FXAlert.info().withText("Header text", "Content text").show();
FXAlert.info().withText("Content text").show();
```

This will produce an Alert of type info with the given texts:

![withText](./img/withText.png)

---

### Brevity, please!

If long method chains aren't your thing, we've got you covered. You can also use static convenience
methods included in FXAlert.

```
```java
FXAlert.showInfo("I'm an info dialog!");
```

![info](./img/info.png)

```java
FXAlert.showWarning("I'm a warning dialog!");
```

![warning](./img/warning.png)

```java
FXAlert.showException(ex, "I'm an exception dialog!");
```

![exception](./img/exception.png)

Note that each short-hand method, also has a builder form:
```java
try {
Expand All @@ -90,7 +108,7 @@ try {

### How about confirmation dialogs, how do those work?

```
```java
Optional<ButtonType> result = FXAlert.confirm().withText("Please confirm!").showAndWait();
result.ifPresent(e -> {
// do something with our result here
Expand All @@ -106,6 +124,11 @@ if (okay) {
// user cancelled or closed window
}
```

This will create an Alert like below:

![confirm](./img/confirm.png)

---

### Input Dialogs
Expand All @@ -129,12 +152,14 @@ users enter the correct data type before submission and prevents entry of other
The allowed type is determined by the appropriate `showAndWaitXXX` method. This prevents runtime errors when trying to
parse the inputs, and saves a developer from having to check the returned data is a valid String/Double/Integer.

![input](./img/input.png)

---

### "Flash" notifications

These are notifications that cause a banner to be temporarily displayed on the lower-right
corner of the screen. The banner appears for a few seconds, then fades out of view.
These are notifications that cause a banner to be temporarily displayed in the lower-right corner of the screen.
The banner appears for a few seconds, then fades out of view.

These can be built and invoked like below:

Expand Down Expand Up @@ -162,6 +187,25 @@ While the Alert class's built-in icons are nice, in order to retrieve their icon
up by the appropriate CSS class. Since the JavaFX stylesheet could change in a future release. It's preferred
that a developer specify their own custom "flash" notification graphic.

A `flash` notification:

![flash](./img/flash.png)

---

### Choice Dialogs

Choice dialogs present the user with a list of choices from which they must pick.
This is invoked by calling the `FXAlert.choose()` method.

```java
FXAlert.choose("Option 1", "Option 2", "Option 3")
.withText("Pick one!")
.showAndWait();
```

![choose](./img/choose.png)

---

### Documentation
Expand All @@ -174,6 +218,8 @@ class, most of the action happens there.
Each public method has thorough Javadoc. Protected, package-private, and private methods should
also define a reasonable Javadoc if they're not straight-forward.

---

### Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md). I'm happy to have you contribute to FXAlert, but I have a few
Expand Down
Binary file added img/choose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/confirm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/exception.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/flash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/withText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3cbe981

Please sign in to comment.