I want to change a boolean attribute, based in main class, through a constructor. This is the code:
public class NewJDialog{
public boolean CHECK;
java.awt.Label label;
.
.
.
Trasporta valore = new Trasporta(CHECK,label);
.
.
.
}
Class2
public class Trasporta implementsMouseListener,MouseMotionListener{
public boolean value;
java.awt.Label label;
public Trasporta(boolean value, java.awt.Label ... pns){
for ( java.awt.Label genericlabel : pns){
genericlabel.addMouseListener(this);
genericlabel.addMouseMotionListener(this);
}
this.value=value;
}
@Override
public void mousePressed(MouseEvent e) {
this.value = true;
}
In this way, CHECK attribute will not become "true".
Can you tell me why? How can I fix it?
Thanks in advance for your reply.