Basic GUI question (showing info from another class)
Hi ive been intensly studying java now for a few weeks and ive moved steadily onto GUI's and my question to the forum is, how do i show information about an objects variable in a label on a GUI form?
ill write some quick code here, please excuse any errors, i hope this will clarify my question
ok so ive created a main class called main
and ive created another class called person
in the main class
=================================
person john = new person(); //created a new object called person
john.setHeight(175);
===================================
==
the person class
======================================
public void person{
int height = -1;
void setHeight(int heightPassed){
height = heightPassed;
}
}
================================
ok so from above you can see i set the object viarable john.height to 175.
Now assuming a created a simple JFrame (GUI) form, how would i then show john.height in a label?
reason why i ask is because the GUI doesnt reconise the object john so whats the way round this?
thank you