Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I'm lost, need help using jtextarea, savedialog

 
tom jenkins
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NEVERMIND, thanks......... dudes.....

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic