Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving JTextArea's Content

 
Dan Hoddinott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Good People,

I know I'm probably giving it up about my acute newbie-ism with this question, but here goes anyway... I am trying to save the contents of a JTextArea using a file menu system in a case where the JTextArea is not the only element in the program.

As an example, the file menu system works fine if the JTextArea is the main element in the program (such as in the case of a simple text editor), but what I'm trying to do is save text that arrived in a JTextArea from a JTextField or other sources.

Is this do-able ... or does the menu act only on the JFrame itself?

Any help would be appreciated.

Dan
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

There's really no such thing as "the file menu system" (in pure Java, anyway; if you're using some sort of application framework outside of the core Java APIs, there may well be.) You create a JMenuBar object, and JMenu objects, and JMenuItem objects, and you can tell each JMenuItem object what should happen when it is selected. So the answer to your question is that yes, it's absolutely possible. The sky's wide open.
 
Dan Hoddinott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
Hi,

Welcome to JavaRanch!

There's really no such thing as "the file menu system" (in pure Java, anyway; if you're using some sort of application framework outside of the core Java APIs, there may well be.) You create a JMenuBar object, and JMenu objects, and JMenuItem objects, and you can tell each JMenuItem object what should happen when it is selected. So the answer to your question is that yes, it's absolutely possible. The sky's wide open.
 
Dan Hoddinott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for responding. Forgive my imprecision of expression (I am a newbie, after all), but what I meant to convey by the clearly unwise "file menu system" reference is that a JMenuBar had indeed been created and that the individual JMenuItems do exactly as advertised in the simple text editor example mentioned. What I'm looking for, then, is the method that would target the JTextArea in the other example I mentioned so that the JMenuItems can act on it.

Again, any help greatly appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic