Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import javax.swing.filechooser.FileNameExtensionFilter;
- public class ChooseFileForAlarm {
- public void ChooseFile(){
- JButton b1 = new JButton();
- JFileChooser fc = new JFileChooser();
- FileNameExtensionFilter filt = new FileNameExtensionFilter("wav", "wav" );
- fc.addChoosableFileFilter(filt);
- fc.setFileFilter(filt);
- fc.setCurrentDirectory(new java.io.File("C:/Users/dns/Desktop/воркспэйс/Game"));
- fc.setDialogTitle("Hello");
- fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if(fc.showOpenDialog(b1)==JFileChooser.APPROVE_OPTION){
- }
- String s = fc.getSelectedFile().getAbsolutePath();
- String z = s.replace('\\', '/');
- //тут установлю стринг, передающую путь к файлу в Chasi
- Chasi ch = new Chasi();
- ch.setRe(z);
- }
- public static void main(String[] args) {
- }
- }
Add Comment
Please, Sign In to add comment