Skip to main content

Bug in JFilechooser?

3 replies [Last post]
christiaan_se
Offline
Joined: 2006-07-13
Points: 0

Hi,
using jdk 1.6u1 on Windows Xp:
- create following folder structure: C:\testwithalongname\New Folder\testwithalongname
- Open JFileChooser with "show list" mode
- Browse to C:\testwithalongname
- New Folder will be displayed as New Fol...

is this a (known) bug?

kind regards,
Christiaan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
loneid
Offline
Joined: 2006-04-13
Points: 0

Hi Christiaan,

I've just tried to reproduce it on my PC with WinXP Pro installed. I tried both Metal and Windows LaF's on 6u1 and 6u2, and didn't notice the behaviour you described, even with twice as longer folder names. Could you please specify a step-by-step scenario to help me to reproduce it?

Cheers,
Leonid Popov
Swing team engineer
Sun Microsystems

> Hi,
> using jdk 1.6u1 on Windows Xp:
> - create following folder structure:
> C:\testwithalongname\New Folder\testwithalongname
> - Open JFileChooser with "show list" mode
> - Browse to C:\testwithalongname
> - New Folder will be displayed as New Fol...
>
> is this a (known) bug?
>
> kind regards,
> Christiaan

christiaan_se
Offline
Joined: 2006-07-13
Points: 0

yes, you are right. I tried reproducing it with a small testcase and the problem didn't occur. I found that it is caused by setting a UIDefault, so I am not sure whether this is a bug or not. Running the code below should reproduce the problem

[code]
package test;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;

public class TestCaseOpenFileDialog extends JFrame {

public TestCaseOpenFileDialog() {
super("test");
setPreferredSize(new Dimension(500, 500));
createContent();
}

public void createContent() {
setLayout(new BorderLayout());
JButton button = new JButton("Open");
button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.showDialog(TestCaseOpenFileDialog.this, "test");
}

});
add(button, BorderLayout.NORTH);
}

/**
* @param args
*/
public static void main(String[] args) {
try {
initializeLookAndFeelDefaults();
TestCaseOpenFileDialog tc = new TestCaseOpenFileDialog();
tc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tc.pack();
tc.setVisible(true);
}
catch(Exception e) {
e.printStackTrace();
}
}

public static void initializeLookAndFeelDefaults() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Border b = BorderFactory.createLineBorder(new Color(249, 177, 25), 1);
BorderUIResource bui = new BorderUIResource(b);
BorderUIResource lbui = new BorderUIResource(BorderFactory.createCompoundBorder(b,
BorderFactory.createEmptyBorder(0, 1, 0, 0)));
UIManager.getDefaults().put("List.focusCellHighlightBorder", lbui);
//uncomment => doesnt cause the problem
//UIManager.getDefaults().put("List.focusCellHighlightBorder", bui);
}

}

[/code]

kind regards,
Christiaan

loneid
Offline
Joined: 2006-04-13
Points: 0

Hi Christiaan,

Thanks for the code you posted! I can reproduce the issue now, and I must say this is a new bug. I've filed a CR: 6550019.

Thanks!