Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes I'm lost, need help using jtextarea, savedialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I Watch "I New topic
Author

I'm lost, need help using jtextarea, savedialog

tom jenkins
Greenhorn

Joined: Apr 18, 2012
Posts: 27
Hi Folks,

I'm trying to write a menu program to be able to open and save like a text editor.. Basically I've used MyJFrame, ect.. to add items and such.. What I need help with is trying to build my "Save" menuitem to save the current open text file onto my computer.

here is my code for my texteditor class




I've been trying to somehow be able to save the text in the Jtextarea to my computer for hours but have not been able to come up or find a solution, can you guys help me out please?

This is what I had so far.. (Scroll to the else if that concerns "Save"). I tried to use the bufferedWriter and getText method for Jtextarea, but I only got null pointer exception.. Is there a simple way to do this simple task??? Thanks. p.s. i know i'm lacking some exception handlers I'm just trying to focus on those later.



and just incase here is my code for BasicFile

tom jenkins
Greenhorn

Joined: Apr 18, 2012
Posts: 27
SO far i got it to create the text file but I can't seem to figure out how to get it to copy the contents of my open jtextarea to the file... My problem is that even when i use getText from the Jtextarea methods it returns nothing.

tom jenkins
Greenhorn

Joined: Apr 18, 2012
Posts: 27
NEVERMIND, thanks......... dudes.....

but all i had to do was set my dt variable to static... that's why i got null..

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm lost, need help using jtextarea, savedialog
 
Similar Threads
Problems loading image into a JLabel located in a JScrollPane
scrollpane not scrolling
Weird actionPerformed method.
How To Add Text to a JPEG image?
closing a jFileChooser window