Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ANY SWING EQUIVALENT FOR SAVE DIALOG IN AWT  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DEAR SIR,

I WANT TO KNOW THAT AS WE HAVE SAVE DIALOG BOX IN AWT
DO WE HAVE ANY SUCH COMPONENT IN SWING.
I AM MAKING AN EDITOR. HOW CAN RUN OTHER EXE FILES FROM
JAVA IF I WANT TO KEEP IT AS A MENU OPTION
KINDLY GUIDE

REGARDS
SRIJAN
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Srijan,
Yes, we do have an equivalent Save Dialog Box in Swing. It can be done using the JFileChooser class. I have written a demo code FYI...Hope it helps you...
import javax.swing.JFileChooser;
private void fileChooserForSave()
{try
{JFileChooser d = new JFileChooser();
d.setCurrentDirectory(new File("."));
int result=d.showSaveDialog(strSaveFileMenuItem);
// strSaveFileMenuItem is the parent Component which calls this method, ex: a toolbar, button or a menu item.
String strFileName=d.getSelectedFile().getName();
// the file name selected by the user is now in the string 'strFilename'.
}
catch(Exception er){}
}
and, for your second question, we can run other exes from Java application by using the System.load() method. And, as an option, I have not tried it....
Hope this info was useful to you.......
Have fun,
Kavitha

Originally posted by SRIJAN:
DEAR SIR,
I WANT TO KNOW THAT AS WE HAVE SAVE DIALOG BOX IN AWT
DO WE HAVE ANY SUCH COMPONENT IN SWING.
I AM MAKING AN EDITOR. HOW CAN RUN OTHER EXE FILES FROM
JAVA IF I WANT TO KEEP IT AS A MENU OPTION
KINDLY GUIDE
REGARDS
SRIJAN

-----------------------------------------------------------------
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!