Question

chooser = new JFileChooser();
chooser.setSize(300, 200);
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
.......
}

This doesn't work. Always opens in default size.

Was it helpful?

Solution

Try chooser.setPreferedSize(new Dimension(300, 200))

OTHER TIPS

Maybe a solution would be to extend the JFileChooser class and overload the constructor with the new setSize method. Not sure if this will work. I know you can extend the very basic JDialog to create custom dialogs and calling setSize there worked for me last time I tried it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top