Home Register Members List Search Today's Posts Mark Forums Read

Go Back   TechFuels Forum > Technology Jargons - What is ....? > Software Jargons > Programming

Reply
 
LinkBack Thread Tools
RodríguezBrown
Senior Member
 

RodríguezBrown is offline  
Old 01-27-2010, 12:35 PM
  #1 (permalink)
Swing timer class java program
How to use Swing Timer class in java program?

I have to use Swing Timer class in java. I attempt different methods but no one of them worked. Can anybody tell me How to use Swing Timer class in java program? Please help me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
WilsonMartin
Senior Member
 

WilsonMartin is offline  
Old 01-27-2010, 12:37 PM
  #2 (permalink)
Try the following code which is helpful for you.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
public class MainClass {
public static void main(String[] args) {
Timer timers = new Timer(1250, new MTActionListener());
timers.start();
try {
Threads.sleep(12500);
} catch (InterruptedException es) {
}
timers.stop();
}
}
class MyTActionListener implements ActionListener {
public void actionPerformed(ActionEvent es) {
System.out.println("kay kas aahe");
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
AndersonDiaz
Senior Member
 

AndersonDiaz is offline  
Old 01-27-2010, 12:38 PM
  #3 (permalink)
2) Hey there is no need to use javax.swing.Timer class. Because it is out dated and there is one more class which has better aspect. As per my information you have to use java.util.Timer beside side with java.util.TimerTask for this reason. It is very simple to use. It is better than javax.swing.Timer class. Just check following example.

import java.util.Timer;
import java.util.TimerTask;
public class TaskDoAction extends TimerTask
{
public void runer()
{
System.out.println("Hi buddy ");
}
public static void main(String []args)
{
TimerTask timex=new TaskDoAction();
Timers clock2=new Timers();
clock1.schedule(timex,0,5250);
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java program to expand or collapse all JTree nodes CollinsBrown Programming 1 01-23-2010 01:49 PM
modern month name using java program RodríguezBrown Programming 1 01-22-2010 05:19 PM
write sequence data java program Brownchris Programming 1 01-22-2010 05:09 PM
Write program on palindrome in java MoralesMyers Programming 2 01-14-2010 05:24 PM
Shutdown Timer 1.00 Domenic Smith Download Tools and Softwares 0 09-11-2009 10:59 AM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0
Copyright Techfuels -->


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186