View Full Version : Help on Timer

04-01-2012, 03:09 PM
Hey guys, I am new to the forum and am new to scripting. Currently I have a script for a basic timer. My goal is for you guys to help me to implement some more parts to this timer. As of now all it has is start/stop and reset. My goal is to have it also include intervals. So basically have it on a loop so it will hit 30seconds, start over hit 10 seconds and repeat this process for like 10minutes. Is this possible and is it easy enough for one of you guys to tamper with the script and help me understand what I should include to get this.

public class TimerMain {
//main function instantiates TimerExample object
public static void main(String[] args){
TimerExample display = new TimerExample();

//imports for TimerExample class:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
import javax.swing.*;
public class TimerExample extends JFrame implements ActionListener {
private JPanel container;
JLabel labelCounter;
private Timer timer1 = new Timer(250, this);
int w,x,y,z = 1;
public TimerExample() {
//set initial delay to 1000 milliseconds

//initialize window
container = new JPanel();

//start timer
* when timer begins this method draws ovals that increase in size
* and descend vertically down the window
public void actionPerformed(ActionEvent e) {
if (z < 100){
Graphics g = container.getGraphics();
w = w+2;
x = x+2;
y = y+2;
z = z+2;
else //stop timer (and drawing) when z coordinate is greater than 99

Philip M
04-01-2012, 05:10 PM
This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

It is your responsibility to die() if necessary….. - PHP Manual

04-01-2012, 05:41 PM
thank you for explaining. haha I feel so stupid, hopefully i'm not the only that makes this mistake.

Philip M
04-01-2012, 06:34 PM
thank you for explaining. haha I feel so stupid, hopefully i'm not the only that makes this mistake.

No. If I had a $ for every time I have posted that message, I could afford a good night out! :) If Javascript was still called Livescript I expect it would not happen.

I have reported your post and asked a mod to move the thread to the right forum.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum