Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Opening & Saving Problem

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic