oldvipera
oldvipera

Reputation: 315

Put an 'ok' or 'open' button in JFileChooser

I have used the JFileChooser option but by default, it shows save and cancel button. I want to put an OK button instead of save button. How do I do that?

Upvotes: 1

Views: 719

Answers (2)

AJ.
AJ.

Reputation: 4534

Maybe this one help:

JFileChooser j = new JFileChooser();
j.showDialog(this, "ok");

Upvotes: 3

piet.t
piet.t

Reputation: 11911

When using one of the showDialog()-variants you can use

showDialog(Component parent, String approveButtonText)

with an approveButtonText of your choice.

If you instanciate your own JFileChooser use

setApproveButtonText(String approveButtonText)

to change the button's text.

Upvotes: 2

Related Questions