Results 1 to 4 of 4
  1. #1
    kkGG is offline Member
    Join Date
    Nov 2010
    Posts
    28
    Rep Power
    0

    Default OpenActionPerformed

    I'm creating a program, which contains a GUI allowing the user to select File:open as part of the standard menu bar options. This is the first time I try to do this but so far I've declared an openActionPerformed method which uses a JFileChooser to create the GUI. thsi is what I have so far...

    Java Code:
    private void openActionPerformed(java.awt.event.ActionEvent evt) {                                     
        JFileChooser openFC = new JFileChooser();
        if (openFC.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            File[] files = openFC.getSelectedFiles();
            for (file : files) { /*unsure what to do here*/ }
        }
        else {
            return;
        }
    }
    how do I actually go about opening the file and displaying it to the user?

    Thanks for you help

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: OpenActionPerformed

    Also take a look at the methods of the java.awt.Desktop class.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    kkGG is offline Member
    Join Date
    Nov 2010
    Posts
    28
    Rep Power
    0

    Default Re: OpenActionPerformed

    Thanks for your replies. The tutorials were very helpful :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •