aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GUI Help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI Help please" Watch "GUI Help please" New topic
Author

GUI Help please

Christopher Docherty
Greenhorn

Joined: Jun 03, 2004
Posts: 4
Hi,

This is my first post on the ranch, and i am hoping someone can help me out.

I am trying to code a GUI that will populate the blank JTextFields, from another class.

The GUI is fine in that it can display the various buttons, labels and text fields, however i cannot figure out how to fill the text fields.

eg. To fill in the name field in the GUI from a completed questionnaire.


I hope I have made sense, and thanks for taking time to read.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Christopher!

I'm moving this to the Swing / JFC / AWT forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Well, there are a couple of ways to access variables from other classes. This really isn't GUI specific as you would do this in almost any Java program.

The first way, and probably the prefered way, is to create your class with getter methods for the values you need. Kind of like a Javabean, but as this Class probably does more than store data..



Then in your other class you would simply do something like



A less coded way of doing the same thing would be to store all your answers in some sort of a Collection class instead of individual Strings.

The other way would be to declare all your variables public and just access them like completedQuestionaire.answer1;

And yet another way is to declare all the variables public static and then you don't even need an instance of your CompletedQuestionaire class. All you have to do is specify the class name and the variable like CompletedQuestionaire.answer1;

Ok, so now that I have throughouly confused you...If you want to try one of those options out and then when you are having problems with the code, you can post the code here and we can help you better.


GenRocket - Experts at Building Test Data
Christopher Docherty
Greenhorn

Joined: Jun 03, 2004
Posts: 4
Thanks for your time.

I will have a go and let you know how i get on.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI Help please