How to open JFileChooser with predefined size
Asked Answered
F

2

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

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

Filmy answered 22/11, 2010 at 13:4 Comment(0)
D
17

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

Dyandyana answered 22/11, 2010 at 13:46 Comment(2)
It is actually chooser.setPreferredSize(new Dimension(800, 600)); and it works. ThanksFilmy
Sorry about leaving off the Dimension. I just typed the method from memory.Dyandyana
E
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.

Equinoctial answered 22/11, 2010 at 13:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.