MichaelJakubec / gtkjfilechooser

Automatically exported from code.google.com/p/gtkjfilechooser
1 stars 0 forks source link

start JFilechooser with spezified directory fails #83

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.if ("GTK look and feel".equals(UIManager.getLookAndFeel().getName())) {
                UIManager.put("FileChooserUI", "eu.kostia.gtkjfilechooser.ui.GtkFileChooserUI");
            }
JFileChooser chooser = new JFileChooser(<any path to a directory>);

What is the expected output? 
The JFileChooser should be in the specified directory,

What do you see instead?
Is always in the home directory

Can you attach an Exception stacktrace or a screenshot?
there are no exceptions

What version of the gtkjfilechooser are you using?
1.4.9

What linux/unix distro are you using and which version of gtk (use "uname
-a" and "pkg-config --modversion gtk+-2.0" to get both information)?

Ubuntu 10.04 gtk 2.12

Please provide any additional information below.

Original issue reported on code.google.com by mic.jaku...@gmail.com on 28 Aug 2011 at 12:19

GoogleCodeExporter commented 9 years ago
Hallo the solution to this problem is in the class GtkFileChooserUI
in the method  doDirectoryChanged(File olddir, File newdir, Object source) line 
1256

if (getFileChooser().getCurrentDirectory().equals(newdir)) {
    // to avoid repeated invocations on the same directory.
    return;
}

here is the problem. Everytime when 
JFileChooser chooser  = new FileChooser(<the selected Dir>);
or 
chooser.setCurrentDirectory(<the new Dir>)
is called the currentDirectory of the FileChooser is already set to the new 
Dir, at the time when the if statement is executed. So the directory will not 
be changed in the view.
Delete this if Statement and everything works fine. 

The statement is needless cause the check is already made by the JFileChooser 
itself

Original comment by mic.jaku...@gmail.com on 28 Aug 2011 at 1:54

GoogleCodeExporter commented 9 years ago
Do you have a patched version of the .jar file with the fix described above 
that I can download? I've done the fix myself and rebuilt but now I get a null 
pointer exception.

Original comment by stroebel...@gmail.com on 15 Nov 2012 at 9:55

MichaelJakubec commented 9 years ago

Duplicate of setCurrentDirectory is not working #85