Swinging Task Dialog (part 1)


I often take inspiration in modern operating system UIs. Windows User Interface is one of those. I stumbled upon Task Dialogs when reading Windows User Experience Guidelines and realized that even though it is a very precisely designed interaction standard, nothing like that exists in the Swing world. Thus I decided to create “Task Dialog” library for Swing.

After approximately a week of designing and coding I can present the first rough “alpha”. The main point is a very simple usage. In future common uses can be simplified even more by using TaskDialogFactory, but now I’m mostly concentrated on functionality.

The simplest dialog can be done in few lines of code:

TaskDialog dlg = new TaskDialog("Task Dialog" );
dlg.setText( "Hello World!" );
dlg.show();

Here is a more Task Dialog like one:

TaskDialog dlg = new TaskDialog("Application Error" );
dlg.setInstruction( "CRASH AND BURN!");
dlg.setIcon( TaskDialog.StandardIcon.ERROR );
dlg.setText( "The applicaiton has performed an illegal action. This action has been logged and reported." );
dlg.show();


Here is task dialog with details

TaskDialog dlg = new TaskDialog("Application Error" );
dlg.setInstruction( "CRASH AND BURN!");
dlg.setIcon( TaskDialog.StandardIcon.ERROR );
dlg.setText( "The applicaiton has performed an illegal action. This action has been logged and reported." );
dlg.getDetails().setExpandedComponent(
       new JLabel( toHtml(" javax.activity.InvalidActivityException \n " +
                          "at com.ezware.dialog.task.TaskDialogTestBed.main(TaskDialogTestBed.java:316)")));
dlg.show();



There is a way to add a footer for important information which may not work anywhere else in the dialog:

TaskDialog dlg = new TaskDialog("Application Error" );
dlg.setInstruction( "CRASH AND BURN!");
dlg.setIcon( TaskDialog.StandardIcon.ERROR );
dlg.setText( "The applicaiton has performed an illegal action. This action has been logged and reported." );
dlg.getDetails().setExpandedComponent(
       new JLabel( toHtml(" javax.activity.InvalidActivityException \n " +
                          "at com.ezware.dialog.task.TaskDialogTestBed.main(TaskDialogTestBed.java:316)")));
dlg.getFooter().setText( "Your application chrashed because a developer forgot to write a unit test");
dlg.getFooter().setIcon( TaskDialog.StandardIcon.WARNING );
dlg.getFooter().setCheckBoxText( "Don't show me this error next time" );
dlg.getFooter().setCheckBoxSelected( true );
dlg.show();


The library is carefully built to work automatically with any look and feel and has a testbed for testing most of the functionality.
Here is few under Nimbus and Metal:


This is the first release. There is lot to more to do. Current plan includes standard components, command links, custom dialog command buttons etc.

I’m planning to continue documenting the development progress in this blog.
The project is available at http://code.google.com/p/oxbow/ under BSD license.
Comments and suggestions are welcome.


7 comments

  1. Pingback: Java desktop links of the week, March 1 | Jonathan Giles

  2. Pingback: Prettier failures using Swing TaskDialog « Schneide Blog


Leave a reply to Pedro Duque Vieira Cancel reply