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

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101

2 Answers2

16

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

Greg Mattes
  • 33,090
  • 15
  • 73
  • 105
Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
0

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.

Simon H
  • 1,735
  • 12
  • 14