• 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

Java Address Book : How to get jtextfield text from another class?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im new to Java and Im doing a address book project. I have 2 classes, the GUI and AddGUI. I want the user input at the AddGUI to show in the jtextfield of the GUI. How do I do it?

GUI class:


AddGUI class:


Thanks.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just a quick reply.
there are two ways.
make the GUI textbox not private. then you can access it from the other class //not recommended
use a setter method in the main class.
either way the helper class will need a reference to the main class.
passed to it either in it's constructor, or a method.
sorry i didn't actually read your code.
 
N Hakim
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the reply. Can you show an example how to use the setter and constructor method?
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i can...hold on...
in fact i demonstrate both methods. i had a compelling reason to make DrawingArea not private.
from the main class:

from the DrawingArea class

you will want to use a String instead of a boolean, but this should give you the idea
 
reply
    Bookmark Topic Watch Topic
  • New Topic