Results 1 to 4 of 4
Thread: OpenActionPerformed
- 01-17-2012, 09:11 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 28
- Rep Power
- 0
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...
how do I actually go about opening the file and displaying it to the user?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; } }
Thanks for you help
- 01-17-2012, 09:20 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Re: OpenActionPerformed
See Lesson: Basic I/O (The Java™ Tutorials > Essential Classes)
And given that method name, I would also recommend reading:
How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
- 01-18-2012, 05:39 AM #3
Re: OpenActionPerformed
Also take a look at the methods of the java.awt.Desktop class.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-19-2012, 04:00 AM #4
Member
- Join Date
- Nov 2010
- Posts
- 28
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks