Tuesday, November 19, 2013

Java: Apply File Filter in AWT FileDialog

Current post is on how to apply File Filter in Abstract Window Toolkit (AWT) FileDialog component on Windows

Started working on AWT in Java and got stuck in FileFilter FileDialog component?

Unable to get the desired filter in FileDialog on Windows?

Just set the required file filter in setFile function of FileDialog
fileDialogObject.setFile(".java");

Because:

In setFileFilter Java documentation it states:
Filename filters do not function in Sun's reference implementation for Microsoft Windows.

 

FileDialog setFile in Java:


FileDialog fileDialogObject = new FileDialog(parentFrame,"Java Files Selection",FileDialog.LOAD);

fileDialogObject.setFile("*.java");

//It will show all the .java extension files in FileDialog Box


For more details refer to Java documentation on FileDialog

Hope this post saved your time.

Appreciate your feedback via comments.

Thanks.
Mehul

No comments:

Post a Comment

Disclaimer:

The above post and all the posts in the blog are derived from facts, information, logical interpretation and logical conclusion of printed and internet materials available to me, perceived and produced by 99 gm brain of mine, which by no means always be accurate, consistent and complete.

All the posts are for personal quick reference only.

If any suggestion, correction, misinterpretation, misconception commented, which will be moderated and deleted if required, to avoid unforeseen issues.

If any trademark / copywrite issue is present, do send in a mail and appropriate tag (logo, name, website link) will be attached to the same.

Additional disclaimer will be attached wherever required in the post.