Java swing file chooser example

-Java swing file Chooser in java is a frame display object that allows you to open or save a file. It looks like this:
Java-swing-file-chooser-example
-Now let's take a simple example of opening and saving files.
Java-swing-file-chooser-example
-File name: DemoJFileChooser.java
Java-swing-file-chooser-example
-Continue DemoJFileChooser.java
Java-swing-file-chooser-example
-In the above code you notice two commands to display under open and save files are different.

  • int select = fc.showOpenDialog (this);
  • int select = fc.showSaveDialog (this);

-The JFileChooser.APPROVE_OPTION argument indicates that you have accepted the "Open" or "Save" file.
-The save and open icons you put in the same package as follows:
Java-swing-file-chooser-example
-Read more custom jtabbedpane in java swing with detail example:

Comments