java - Creating a timer and displaying it in a textbox (activated by a button) -
as far understand, should simple this, however, not errors, nor program run.
public class test extends applet implements actionlistener { jtextfield tf = new jtextfield(); timer timer = new timer(); int counter = 30; public void init() { setlayout(null); tf.setbounds(10,10,100,40); tf.addactionlistener(this); add(tf); } public void actionperformed(actionevent e) { timer.scheduleatfixedrate(new timertask() { public void run() { counter = counter - 1; } }, 2*60*1000, 2*60*1000); tf.settext(""+counter); } public static void main(string[] args) { } } please, bear in mind complete beginner, , yes, did search around web while, before coming here help, , please, detailed possible..
any / criticism appreciated! thank in advance!
you have main() without code. app should initialized:
public static void main(string[] args) { test app = new test(); app.init(); } otherwise test class never open.
Comments
Post a Comment