I need help with jFilechooser.

I've already made the jFilechooser. The problem is that I want to change the text of the "save" butten to "Ok", as I need it to perform a save function, as well as a read function, on different occasions.

Changing the code where the jFilechooser is instantiated is not an option, since the whole thing is done with Netbeans's GUI editor, so the code for the jFilechooser is not editable.

Any assistance would be greatly appreciated.

Recommended Answers

All 3 Replies

Have you looked the API for JFileChooser?

at default you can get OPEN dialog...

if you want SAVE button then you call code below...

JFileChooser.showSaveDialog(this);

put if else condition then call corresponding dialogue....


add reputation point if it is helpful to you

Thanks guys.

I found the solution.

Lets assume the name of the JFilechooser is fc.

fc.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);

^ will make it a save dialog

fileChooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG);

^ will make it an open dialog.

Thanks for the advice. +++REP!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.