Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

FileChooser Trouble

  • 24-01-2005 01:20PM
    #1
    Closed Accounts Posts: 2


    i Want to save files and open files using the filechooser and i dont now how to make it open the file i selected e.g a "txt" document. If any one can help it would be great thanks. Sorry in java please

    ImageIcon openIcon = new ImageIcon("images/open.gif");
    JButton openButton = new JButton("Open a File...", openIcon);
    openButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int returnVal = fc.showOpenDialog(FileChooserDemo.this);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    //this is where a real application would open the file.
    log.append("Opening: " + file.getName() + "." + newline);
    } else {
    log.append("Open command cancelled by user." + newline);
    }
    }
    });


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Any language in particular you'd like the answer in? :rolleyes:


Advertisement