Hi everybody:
I'm working on a program that has to change the value of a variable every minute, I start by defining the GUI and a Timer object, to listen when the value must change, by this way:
import ...
public class changeValue extends JFrame implements ActionListener{
private JLabel valVar;
private int delay = 60000;
private Timer myTm;
private contain;
public changeValue(String value){
contain = getContentPane();
valVar = new JLabel(value);
contain.add(valVar);
setSize(200,200);
setVisible(true);
}
public void chgVal(String newVal){
valVar.setText(newVal);
}
public void start(){
//all the timer stuff here...
}
public void main...{
changeValue app = new changeValue("1");
app.start();
}
public void actionPerformed(ActionEvent e){
chgVal("2");
}
}
but when i run this program i recived a Null Pointer Exception, that means i can access this JLabel component properties, can anyone help me? Thanks.
mac2k.
I'm working on a program that has to change the value of a variable every minute, I start by defining the GUI and a Timer object, to listen when the value must change, by this way:
import ...
public class changeValue extends JFrame implements ActionListener{
private JLabel valVar;
private int delay = 60000;
private Timer myTm;
private contain;
public changeValue(String value){
contain = getContentPane();
valVar = new JLabel(value);
contain.add(valVar);
setSize(200,200);
setVisible(true);
}
public void chgVal(String newVal){
valVar.setText(newVal);
}
public void start(){
//all the timer stuff here...
}
public void main...{
changeValue app = new changeValue("1");
app.start();
}
public void actionPerformed(ActionEvent e){
chgVal("2");
}
}
but when i run this program i recived a Null Pointer Exception, that means i can access this JLabel component properties, can anyone help me? Thanks.
mac2k.