Trouble configuring the AWT file chooser [message #991804] |
Thu, 20 December 2012 03:36  |
Eclipse User |
|
|
|
I am using a FileChooser in two places. In one place I directly create a new FileChooser instance as described in this thread. In the other place I use a FileChooserField in a form.
In both cases I am able to set the default path, the default file name, the file extensions to use in the extension drop down box.
However, I think the default file chooser is ugly as sin, so I added the following code to my SwingEnvironment class to use the native windows file dialog instead:
@Override
public ISwingScoutFileChooser createFileChooser(Window w, IFileChooser fc) {
ISwingScoutFileChooser ui = new SwingScoutFileChooser(this, fc, w, true);
decorate(fc, ui);
return ui;
}
This works and lets me use the windows file dialog, however, it seems that this ignores any parameters I set on the file chooser.
- I cannot set a default directory (it seems the file dialog under windows 7 manages that on its own)
- I cannot set the extension for the extension drop down box (I always have the single entry "All files (*.*)" in there. Instead, the extension I define are used as title text for the FileDialog
- I does honour the filename that I set
Is there something more I need to do to make sure the FileChooser.setXxxx() methods have an effect for the native (AWT) file chooser? If not, I can live with not being able to set a specific directory and just having the file dialog use the last one I selected a file from. I can live with not being able to populate the extension filter dropdown, but the extensions showing in the title bar is truly annoying!

Is there a way to get rid of the extensions from the title bar?
|
|
|
|
|
|
|
Re: Trouble configuring the AWT file chooser [message #1001505 is a reply to message #997076] |
Wed, 16 January 2013 15:57   |
Eclipse User |
|
|
|
Hi Urs,
I can't see any reason too why the methods showFileChooserSwing and showFileChooserAWT should have the private modifier since this limits the extensibility of the file chooser. It makes sense to declare the modifier as protected to allow them to be exchanged by another implementation.
Furthermore, it would probably be reasonable to move the code
if (m_owner instanceof Dialog) {
dlg = new FileDialog((Dialog) m_owner, buf.toString(), openMode ? FileDialog.LOAD : FileDialog.SAVE);
}
else if (m_owner instanceof Frame) {
dlg = new FileDialog((Frame) m_owner, buf.toString(), openMode ? FileDialog.LOAD : FileDialog.SAVE);
}
else {
dlg = new FileDialog(new Frame(), buf.toString(), openMode ? FileDialog.LOAD : FileDialog.SAVE);
}
to a protected factory method. In your case you could ignore the string buffer containing the file extension and leave or set a different title for the dialog.
I'm going to assign the Bugzilla 397381 to me.
Cheers,
Ken
|
|
|
|
Powered by
FUDForum. Page generated in 0.25110 seconds