In the
form class, which we’ll call GUI
slave
s = new slave(this);// slave is the other class and “this” is a reference to itself,
the GUI
In the
other class, which we’ll call slave
GUI
form; // where GUI is the name of the form class
public slave(GUI formObject)//formObject is
a reference to the GUI form passed by “this”.
{
form = formObject;
//form.setVisible(true); // not needed
as it’s already visible
}
void
changeButton()
{
form.setButtonText("hello");
// The setButtonText method is an accessible method in the GUI form
}