This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi every body,
Can I add "Open Button" in Save Dialog of JFileChooser like File Download's dialog?
How can I add a dialog same with File Download's dialog in Swing application?
Sorry for stupid question!!!
As per your attachment, the user has already chosen a file.
What you can do is present the user with a file chooser.
If you use JFileChooser.showDialog() method, you can specify the button text. Just check out the API on how to use it.
When the user has selected a file, you can present him with another dialog with a choice of open./save/cancel. For this JOptionPane suggests itself.
You want to open an excel file in your application (display contents of the excel file on your UI) or from your application?
If you want the latter, search the forums as this question comes up quite frequently. You will find a solution which is platform independent.
Julian Trung wrote:Sorry,
I mean now Save File Dialog has 2 button: Save and Cancel button, I want to add another button like "Open Button" so my dialog will has three buttons like attached image below
That's not a JFileChooser type dialog. It is a regular dialog with some labels, icons, buttons and a hyperlink. Only if you press Save will a file chooser be shown.
You could do the same yourself, by making a custom JDialog subclass. Save will call the JFileChooser, Cancel will close the dialog and Open will open the file. (That is a bit harder than the rest though). You'll have to play around a bit with the layout as well.
As for the hyperlink, if you really need one there are some examples on Java2S.