Sunday, March 7, 2010

Swinging Task Dialog (part 2)

This week's focus was on adding more functionality.
The API was extended with an ability to set commands (buttons on the bottom of the dialog). TaskDialog features a set of standard commands ( currently only Ok and Cancel ). But it is very easy to add any arbitrary command. The only requirement is that the command has to implement TaskDialog.Command interface.
TaskDialog's getResult() method returns last executed command. A simpler way to use it is show() method which shows the dialog and returns last executed command. Here is a warning dialog:




Media_httpmcojfileswo_dkhfw

Sometimes custom command has to not just close the dialog but execute some additional logic.  To accomplish this PropertyChangeListener can be attached to the TaskDialog's "result" property. As soon as result changes (command button is pressed ) your code will be notified.
It is possible now to add any fixed component to the dialog ( in addition to expandable one ). Here is the example of the  dialog with the progress bar.




Media_httpmcojfileswo_tjdli


More work is required in the area as I want to to provide prebuilt components such as command links. To even further simplify usage I added TaskDialogs class. It makes creation of certain task dialogs a one liner.



The above code produces three task dialogs:

Media_httpmcojfileswo_gijcu
Media_httpmcojfileswo_lwldg
Media_httpmcojfileswo_xedvc

The project is available at http://code.google.com/p/oxbow/ under BSD license.
As always - comments and suggestions are welcome.

4 comments:

  1. Prettier failures using Swing TaskDialog « Schneide BlogMarch 24, 2013 at 11:16 AM

    ReplyDelete
  2. Java desktop links of the week, March 15 | Jonathan GilesMarch 24, 2013 at 11:16 AM

    ReplyDelete