Eclipse Zone is brought to you in partnership with:

Starting 2008, I am working with Oracle at San Francisco office. I am at Utilities division with my primary focus on frameworks and tools. Prior to Oracle, i worked with Pramati Technologies for almost 1.5 year. With the SOA and Mashups focus during 2007 and 2008, I was fortunate to know and work closely with industry’s best Mashup company (JackBe). I have spent nearly 6.5 years in Robert Bosch GmbH, Germany as an Automotive Industry Software Consultant. Suresh has posted 6 posts at DZone. You can read more from them at their website. View Full User Profile

Discover Eclipse's JFace Dialogs

  • submit to reddit

The JFace framework of Eclipse provides many standard and useful dialogs and a framework to build custom dialogs and wizards. When the standard dialogs seems to be too simple for your plugin or RCP developement, one can extend the standard dialogs to suit their own needs. The aim of this article is to provide example oriented approach to dialogs and see in depth of all frequently used dialogs. I am hoping to have this article as the point of reference for many developers to get an overview of Dialogs.

Dialogs are modal UI components which would do some user interaction tasks. Traditionally Dialogs are used to enter a simple input, to select a choice from a list, to select multiple nodes from a tree, to inform about a success/failure from an operation, to input confirmations from the user, and so on.

Eclipse provides standard dialogs from two different frameworks, SWT provides very basic dialogs like FontDialog, ColorDialog, DirectoryDialog, FileDialog and FontDialog. These SWT dialogs are coming out of the SWT as they are very basic and has close connection to the OS. All these Dialogs are available from org.eclipse.swt.widgets package from the org.eclipse.swt.<platform>.jar.

JFace provides a variety of Dialogs for the implementors to extend or to use them directly. Its interesting to look into variety of dialogs provided by JFace and i would leave the usage to your imagination and context. Rest of this article is mostly code, screen shots and less of textual description. I tried to keep the short, sweet and simple.


This is a SWT Dialog but worth mentioning under the general concept of the Dialogs.

"Instances of this class allow the user to navigate the file system and select or enter a file name. Note: Only one of the styles SAVE and OPEN may be specified. IMPORTANT: This class is intended to be subclassed <em>only</em> within the SWT implementation."

FileDialog fsd = new FileDialog(shell);
fsd.setFilterExtensions(new String[] {"*.jpg"});
fsd.setText("Select My JPG Files...");;


File Dialog


Published at DZone with permission of its author, Suresh Krishna. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Florian Potschka replied on Sun, 2008/03/16 - 3:20pm

Great list! The JFace-dialogs are very powerful and easy to handle.

Mark Dexter replied on Thu, 2008/03/20 - 9:11pm

Hi. I'm using Eclipse 3.3 and I don't have the ElementListSelection or any of the ones you discuss after this. Are these new in 3.4? Thanks.

Florian Potschka replied on Fri, 2008/03/21 - 9:24am in response to: Mark Dexter

No, as far as I know, the ElementListSelectionDialog exists at least since 3.1. Have you imported all necessary packages and dependencies? Perhaps the Eclipse QuickFix (Ctrl+1) solves your problem.

Mark Dexter replied on Fri, 2008/03/21 - 11:12am

Thanks, Florian. These classes are contained in the JAR org.eclipse.ui.ide_*.jar file. It is a little difficult to figure out which JAR files are required to supply all of the JFace packages. I now know about 6: com.commands, equinox.common, jface, jface.text, text, and now ui.ide. Thanks. Mark

Mark Dexter replied on Fri, 2008/03/21 - 3:31pm

I spoke to soon. The file "org.eclipse.ui.ide*.jar" is NOT the right one. It has a package called org.eclipse.ui.dialogs, but not these classes.

 The correct JAR file is "org.eclipse.ui.workbench*.jar". This has all of the missing dialog classes. Thanks.

Mark Dexter replied on Fri, 2008/03/21 - 4:11pm

Well..., it appears that you also need the JAR org.eclipse.osgi_*.jar. Otherwise, it can't find the org.eclipse.osgi.util.NLS class (whatever that is). So I'm up to 7 external JAR files to use JFace. Mark

 Later that day ... It works great! Six lines of code replaces 3 whole classes. Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.