Java Timers
Saturday, 3 May 2014
we are using netbeans ide in this project developed on windows 7 ,
create new project—>java—> java desktop applcation
Now go to source view of netbeans ide define three(3) class type variable
Timer tim;
String [] caps={"java","c++","c","fortran"};
int count=0;
There after locate
super(app);
initComponents();Just below initComponents();
Define a method named as timerstart();
now define timerstart() method in class
as follows
public void timerstart()
{tim=new Timer(500,new ActionListener()
{public void actionPerformed(ActionEvent e)
{
if(count>3)
{
count=0;
}
jLabel1.setText(caps[count]); //iterate through text in array caps
count+=1;
}
});
tim.start();}
It is a very usefull component for doing realtime functions
I wish you all like this please post your usefull comments and like.
Thanks