Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-19T02:50:46.000Z (over 2 years ago)
- Last Synced: 2023-05-01T17:38:22.264Z (over 1 year ago)
- Size: 1000 Bytes
- Stars: 0
- 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:- ![image](https://user-images.githubusercontent.com/96234273/179653539-e9cded32-5463-4d4a-9557-3dd5dc0e5fd0.png)
click on Browse then the files or folder of this pc.
![image](https://user-images.githubusercontent.com/96234273/179653746-19bfe34c-7872-462c-8281-66219bc3915a.png)
*/