https://github.com/sumitkumargiri/create-filechooser-in-java
https://github.com/sumitkumargiri/create-filechooser-in-java
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sumitkumargiri/create-filechooser-in-java
- Owner: SumitKumargiri
- Created: 2022-07-19T02:45:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-19T02:50:46.000Z (over 3 years ago)
- Last Synced: 2025-01-19T14:20:33.989Z (about 1 year ago)
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# create-Filechooser-in-java
import javax.swing.*;
import java.awt.event.*;
class fr12 extends JFrame implements ActionListener {
JTextField tf;
JButton bt;
JFileChooser JFC;
fr12() {
setLayout(null);
setLocationRelativeTo(null);
tf = new JTextField();
tf.setBounds(50, 100, 200, 30);
add(tf);
bt = new JButton("Browse");
bt.setBounds(100, 150, 100, 30);
add(bt);
bt.addActionListener(this);
JFC = new JFileChooser("c://");
JFC.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
// add(JFC);
setSize(500, 500);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
int ans = JFC.showOpenDialog(this);
if (ans == JFileChooser.APPROVE_OPTION) {
tf.setText("Cancel Clicked.....");
}
}
public static void main(String args[]) {
fr12 obj = new fr12();
}
}
/* output:- 
click on Browse then the files or folder of this pc.

*/