At a guess,
jtextfield
is defined as an instance member of the class
classB
, but you're trying to access it like a class (
static
) member.
This is a common problem for users coming from VB.NET, since VB.NET creates a default instance of your
Form
classes for you, and makes them available as global variables with the same name as the class. (So
Form1.TextBox1
accesses the control on the default instance of the
Form1
class.) This was done for backwards-compatibility with VB6, and always causes confusion for people moving to a different language!
You'll need an instance of the class in order to access the instance members:
public first(classB theOtherClassInstance) {
initComponents();
if (jCheckBox1.isSelected()) {
theOtherClassInstance.jtextfield.setText("That's it !");
}
}
NB: It always helps if you post the error message you're getting. :)