|
1 | 1 | # JavaFXTaskbarProgressBar |
2 | | -## This library allows you to add taskbar progressbars to your javafx stages. |
3 | | -The library uses another library called [Bridj](https://github.com/nativelibs4java/BridJ). |
4 | | -With the Bridj library you can add taskbar progressbars only to the old swing JFrames, |
5 | | -but not for your javafx stages. But this library will be your solution i hope :). |
| 2 | +## This library allows you to add native taskbar-progressbar functionality to your JavaFX stages. |
| 3 | +The library uses another library called [bridj](https://github.com/nativelibs4java/BridJ) that |
| 4 | +can give access to native operations in java. With the Bridj library you can easily add taskbar progressbars |
| 5 | +to the old swing JFrames but for javafx stages it's too complicated to achieve.<br> |
| 6 | +<b>This library is for you who want to easily use this amazing native functionality with JavaFX!</b> |
| 7 | + |
| 8 | +## Compatibility |
| 9 | +This library only works with java 8 but java 11 support is coming soon! |
| 10 | + |
| 11 | +## Background: what are taskbar progressbars? |
| 12 | +Since Windows 7 there is a taskbar-progressbar feature in Windows systems. |
| 13 | +A good example for this when you copy something using the file explorer:<br> |
| 14 | + <br> |
| 15 | +This library allows you to do this in java (with javaFX)! |
6 | 16 |
|
7 | 17 | ## How to include it to your project |
8 | 18 | You can download the jar file from the releases. |
| 19 | +Every release has two jar files: one is a fat jar that contains the bridj binaries |
| 20 | +as well (so if you use this you don't have to include bridj separately for your project); |
| 21 | +and another jar that doesn't contain the external bridj binaries (in this case you have |
| 22 | +to download it separately). |
9 | 23 |
|
10 | | -## How to use it |
| 24 | +## How to use it in practice |
11 | 25 |
|
12 | | -Create your stage: |
13 | | -```java |
14 | | -Stage stage = new Stage(); |
15 | | -``` |
| 26 | +### Types of progressbar |
| 27 | +Before we jump in we have to know the 4 types of a taskbar-progressbar:<br> |
| 28 | +* `NORMAL` - a progressbar with normal green color |
| 29 | +* `PAUSED` - a progressbar with a yellow color |
| 30 | +* `ERROR` - a progressbar with a red color |
| 31 | +* `INDETERMINATE` - a progressbar that doesn't show any fix progress |
| 32 | +* `NO_PROGRESS` - a progressbar that doesn't show anything |
| 33 | +<br><br> |
| 34 | +All these types are represented by an enum called `com.nativejavafx.taskbar.TaskbarProgressbar.Type`. |
| 35 | + |
| 36 | +Now let's see how can we actually use this through code.<br> |
| 37 | +There are multiple ways to create taskbar progressbars with this library: |
16 | 38 |
|
17 | | -Then, you have to create the TaskbarProgressbar object: |
| 39 | +#### Static methods |
| 40 | +Firstly you have to import the necessary class: |
18 | 41 | ```java |
19 | | -TaskbarProgressbar taskProgressbar = new TaskbarProgressbar(stage); |
| 42 | +import com.nativejavafx.taskbar.TaskbarProgressbar; |
| 43 | +``` |
| 44 | +...and you have to show the javafx Stage before any operation: |
20 | 45 | ``` |
21 | | -Before you start the taskbar progressbar, you must show the stage |
| 46 | +primaryStage.show(); |
| 47 | +``` |
| 48 | +Then call the static method: |
22 | 49 | ```java |
23 | | -stage.show(); |
| 50 | +TaskbarProgressbar.showCustomProgress(primaryStage, 50, 100, TaskbarProgressbar.Type.NORMAL); |
24 | 51 | ``` |
25 | | -Now you can do everything that the taskbar progressbar can do, for example you can show a progress: |
| 52 | + |
| 53 | +It looks okay but it's not safe to do that. This functionality isn't supported by every OS. |
| 54 | +<b>If you use this way to create taskbar progressbars you always have to check that the current OS |
| 55 | +supports this functionality!</b> |
| 56 | + |
| 57 | +So let's correct the code: |
26 | 58 | ```java |
27 | | -taskProgressbar.showOtherProgress(50, 100, TaskbarProgressbar.TaskbarProgressbarType.NORMAL); |
| 59 | +if (TaskbarProgressbar.isSupported()) { |
| 60 | + TaskbarProgressbar.showCustomProgress(primaryStage, 50, 100, TaskbarProgressbar.Type.NORMAL); |
| 61 | +} |
28 | 62 | ``` |
29 | | -It will creates this view at the taskbar: |
30 | | -. |
31 | 63 |
|
32 | | -There are 5 types of the taskbar progressbar: |
| 64 | +<b>Result:</b><br> |
| 65 | + |
33 | 66 |
|
34 | | -`TaskbarProgressbar.TaskbarProgressbarType.NORMAL` - It is the normal progressbar with the green color |
35 | | -`TaskbarProgressbar.TaskbarProgressbarType.ERROR` - It is the error progressbar with the red color. |
36 | | -`TaskbarProgressbar.TaskbarProgressbarType.PAUSED` - It is the paused progressbar with the yellow color. |
| 67 | +You have to do a similar thing if you want to show an indeterminate progress: |
| 68 | +```java |
| 69 | +if (TaskbarProgressbar.isSupported()) { |
| 70 | + TaskbarProgressbar.showIndeterminateProgress(primaryStage); |
| 71 | +} |
| 72 | +``` |
| 73 | +<b>Result:</b><br> |
| 74 | + |
37 | 75 |
|
38 | | -`TaskbarProgressbar.TaskbarProgressbarType.NO_PROGRESS` - It is the empty progressbar |
39 | | -`TaskbarProgressbar.TaskbarProgressbarType.INDETERMINATE` - It is the indeterminate progressbar. It doesn't show any fix progress. |
| 76 | +To stop the progress: |
| 77 | +```java |
| 78 | +TaskbarProgressbar.stopProgress(primaryStage); |
| 79 | +``` |
| 80 | +#### Through instantiation |
| 81 | +Firstly (after you imported the necessary class) create a `TaskbarProgressbar` instance: |
| 82 | +```java |
| 83 | +TaskbarProgressbar progressbar = TaskbarProgressbar.createInstance(primaryStage); |
| 84 | +``` |
| 85 | +Before any operation you have to show the Stage: |
| 86 | +```java |
| 87 | +primaryStage.show(); |
| 88 | +``` |
| 89 | +After that just use the created instance for the operations: |
| 90 | +``` |
| 91 | +progressbar.showCustomProgress(50, 100, TaskbarProgressbar.Type.NORMAL); |
| 92 | +``` |
| 93 | +<b><i>Note: in this case to check that the OS supports this functionality is unnecessary |
| 94 | +because the object checks it automatically!</i></b> |
| 95 | + |
| 96 | +The result is the same:<br> |
| 97 | + |
40 | 98 |
|
41 | | -If you want to show an indeterminate progress: |
| 99 | +If you want an indeterminate process: |
42 | 100 | ```java |
43 | | -taskbarProgressbar.showIndeterminateProgress(); |
| 101 | +progressbar.showIndeterminateProgress(); |
44 | 102 | ``` |
45 | | -If you want to stop the progress: |
| 103 | +To stop the progress: |
46 | 104 | ```java |
47 | | -taskbarProgressbar.stopProgress(); |
| 105 | +progressbar.stopProgress(); |
48 | 106 | ``` |
| 107 | +#### Full example |
| 108 | + |
| 109 | + |
| 110 | +## More screenshots |
| 111 | +Some more screenshots about what can you do with this library |
| 112 | +* A paused progress example:<br> |
| 113 | +Code: `progressbar.showCustomProgress(70, 100, TaskbarProgressbar.Type.PAUSED);`<br> |
| 114 | + |
| 115 | +* An error progress example:<br> |
| 116 | +Code: `progressbar.showCustomProgress(40, 100, TaskbarProgressbar.Type.ERROR);`<br> |
| 117 | + |
0 commit comments