• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextArea question - accessing and code structure

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First: I'm new to this. I've searched around a bit but think a human might be able to answer my question better than the search engines so far.

So I understand that you create a class representing your GUI, add a bunch of controls to it, then start running it. My question is twofold: one relates to structure, one relates to how to access a text box.

So here's the code:


Here are the questions:
1. Let's say I want to open a file and input all the contents into the JTextArea "txtBox". How do I access that control to add text to it?
2. Where should I do that? To clarify: what method should I add or utilize to do that. I don't think it should be in the constructor JCheck() if I insert multiple files - should I create another function to do this? And where should I call it from? The run() function?

I know these are fairly entry level questions but I'd like to set myself straight before I start writing poorly formed Java code and any references you can point me to would be awesome too.

Thanks for your time!
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it really your intention to waste everyone's time by encouraging duplicate responses?

http://www.java-forums.org/awt-swing/31852-accessing-jtextarea-after-creation-intro-level-question.html
 
James Ferrara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am maximizing the responses by double posting, yes.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> I am maximizing the responses by double posting, yes.

double posting is fine, provided you include a link to the other post so everyone can see what's already been suggested/tried.

without the link, people like me (who read multiple forums) will just add you to a personal ignore list, so your
attempt at 'maximizing the responses' has the reverse effect.
 
James Ferrara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies. In the future I will do so.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:is it really your intention to waste everyone's time by encouraging duplicate responses?

http://www.java-forums.org/awt-swing/31852-accessing-jtextarea-after-creation-intro-level-question.html


Michael, thanks for the heads-up.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael.

James,
Please read http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
 
James Ferrara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:Thanks Michael.

James,
Please read http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites



Speaking of redundancy, you should read my apology above.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you followed/understood the suggestions given at java-forums?

did they work, or do you still have a problem?

if still a problem, let us know what you've tried and what happened vs what you expected to happen

> before I start writing poorly formed Java code

one thing not mentioned yet is extending a component (JFrame), just for the sake of extending it.
google 'Composition vs Inheritance' for detailed explanations
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic