Results 1 to 3 of 3
- 09-04-2011, 11:58 PM #1
Help with using a jbutton actionlistener to open a text file
Hey Guys,
I've been building a contact editor GUI using Netbeans 7, and I'm stuck on how to open a text file with a button. I've searched around, but only found advice relating to jfilechooser. The text file contains all the entries submitted to the contact editor, and I don't need it to be opened within the GUI, just with notepad outside of the program.
Any help is appreciated!
- 09-05-2011, 12:34 AM #2
Re: Help with using a jbutton actionlistener to open a text file
The button's action listener method would call a method in one of the following classes.how to open a text file with a button
Look at the Desktop class. It will ask the OS to provide the program to open a file.with notepad outside of the program.
If you want to specify which program to use, see the Process and Runtime classes where you can specify the full ccommand line to be executed.
- 09-05-2011, 12:38 AM #3
Re: Help with using a jbutton actionlistener to open a text file
Why do you need to open the file in Notepad? Why can't you display the file on a JTextArea or a JEditorPane?
If you are determined to use Notepad then you can investigate Runtime.exec but make sure you google "pitfalls of runtime exec" or something similar.
Similar Threads
-
open text document using JButton
By coopc in forum New To JavaReplies: 3Last Post: 05-04-2011, 12:02 AM -
JButton ActionListener problems
By Fortu in forum New To JavaReplies: 6Last Post: 02-05-2011, 04:20 PM -
Applet program to open a text file and display the content in text area
By bitse in forum Java AppletsReplies: 0Last Post: 12-09-2010, 05:56 PM -
text editor does not open file
By globo in forum Advanced JavaReplies: 2Last Post: 11-21-2010, 07:39 PM -
How correctly open text file?
By artemff in forum CLDC and MIDPReplies: 3Last Post: 12-23-2009, 06:39 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks