Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Opening & Saving Problem  RSS feed

 
Jan Michael Soan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JFrame with 2 buttons namely button1 & button2. The primary role of button1 & button2 is to open-up a dailog to open & save documents.
1.) button1 should open the file and append it to my JTextArea.
2.) button2 should save everything on my JTextArea.
Before they can do this, I need to pass my 2 methods which are openFile() and openSave() to my button1 & button2 Action Listner.
My problem is that I cant seem to open and save files on my JTextArea. Can anyone pls, look if I forgot something or there is an error. If you may can you tweak my codes so that I can do opening & saving on my documents.
Thank you . . .
Here's the process >>>
button1.ActionListner {
openFile();
}
button2.ActionListner {
openSave();
}
Here's my codes :
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You didn't tell us exactly what you expected to happen, and what happened instead, so I have to try to read your mind...
The openFile() method gets to the point where there's an ObjectInputStream from which you could read serialized objects (don't know what your plan is as far as putting serialized objects into a jtextarea, but I'll assume you have one.) Anyway, once it's created the inputstream, it doesn't do anything with it, so there should be no observable result. Am I missing something?
The saveFile() method stops even earlier: it gets only as far as finding out what the selected file name is.
So what's the problem, exactly?
 
Jan Michael Soan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of my button's just opens the dailog, thats it.
It wont open any .doc or .java file it wont append to the JTextArea the worst is it wont save any thing from my JTextArea and your correct it will go from finiding file and thats it, cause what I plan is to save everything on my JTextArea as a .java file or .doc and then open them by appending it to the JTextArea.
Is there something missing on my methods ?,
thank you for asking.
[ September 13, 2003: Message edited by: Jan Michael Soan ]
 
Jan Michael Soan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I've tried to open the .java or .doc to append
in my JTextArea but did not worked.
text1 is my JTextArea

On saving I dont know really what to do.
[ September 13, 2003: Message edited by: Jan Michael Soan ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!