Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

FileChooser Trouble

Options
  • 24-01-2005 2: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