Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method to retrieve information and output in GUI

 
Jean Maurice milazar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a function which which take an argument to retrieve information from a database. My problem is that the result obtained should be output through a GUI. The function is trigerred at the GUI using using a button event. The code is as follows.



can anyone indicate me where i got things wrong and how i can make the method return the values one at a time and output them if i have textfields.(nametxt, addresstxt, agetxt..etc)
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you applying the information to your GUI? You are simply printing it to System.out. There is an example in the Java™ Tutorials about writing an Applet, and this section about tables may help too.
 
Jean Maurice milazar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its actually the problem that i am having. I dont know how to apply the information to my GUI. The method is situated in different class than that of my GUI. It is only called there and expected to output its values through the text boxes.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which books do you have access to? Lots of books have such examples in; for example Deitel and Deitel has an example using MySQL and the names of their books, and there is an example in Horstmann and Cornell but I can't remember the details of their database.
 
Jean Maurice milazar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of these books are available here. We have mastering javase1.4 and introductory java books. Is there a link where i can get access to electronic copy of these.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many tech books are available through Safari: http://my.safaribooksonline.com/
 
Jean Maurice milazar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the books i have read i've seen some additional lines that i should add to my code. I have added variables to take the values in the function.

But when i passed these variables to my textfield using the setText method i dont get the result. The modifiton is shown in the code and the way i call my method after that.




e.g method call is as follows.
OnclickBtnRetrieve{
viewStaffDetail (36);
txtLastname.setText(lastname);
txtFirstname.setText(firstname);
}

The values are still not shown in my textfields.

 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you setting up your text fields?

And please make sure not to show # # in quoted code; it makes it difficult to test.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic