Sunday, 1 March 2015

How To Create Save File Chooser In Java

This tutorial shows how to create simple  save File Chooser in java.For open file chooser see How To Create Open File Chooser In Java .Following are the steps for creating save file chooser in java.

SAVE FILE CHOOSER:

Creating of open file chooser requires two steps:
  1. JFileChooser save = new JFileChooser();                            
  2. int option = open.showOpenDialog(this);                             

CODING:

import javax.swing.*;
import java.awt.*;
class myjframe1 extends JFrame {

public myjframe1() {

setTitle("save FileChooser");
setSize(300, 200);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);        
JFileChooser save = new JFileChooser();
int option = save.showSaveDialog(this);
}
}
class simpframe
{
public static void main(String args[])
{
myjframe1 x= new myjframe1();
}
}

OUTPUT:



1 comment:

  1. how to do the textarea operation like save textarea info to text file cut, copy, past, save as txt file ..etc

    ReplyDelete