Hello generous java coders!I am really in a desperate situation now. I have a working gui code here:

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class CountdownTimer extends JFrame  {

    JLabel promptLabel, timerLabel;
    int counter;
    JTextField tf;
    JButton button;
    Timer timer;

    public CountdownTimer() {
        setLayout(new GridLayout(2, 2, 5, 5));
        promptLabel = new JLabel("Enter time: ", SwingConstants.CENTER);
        add(promptLabel);

        tf = new JTextField(5);
        add(tf);

        button = new JButton("Start timing");
        add(button);

        timerLabel = new JLabel("Waiting...", SwingConstants.CENTER);
        add(timerLabel);

        event e =  new event();
        button.addActionListener(e);


    }


    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    public void run() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public class event implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            int count = (int)(Double.parseDouble(tf.getText()));
            timerLabel.setText("Time left: " + count);

            TimeClass tc = new TimeClass(count);
            timer = new Timer(1000, tc);
            timer.start();

        }
    }

    public class TimeClass implements ActionListener {
        int counter;

        public TimeClass(int counter) {
            this.counter= counter;

   }
        public void actionPerformed(ActionEvent tc) {
            counter--;

            if(counter >= 1) {
                timerLabel.setText("Time left: " + counter);

            }
            else {
                timer.stop();
                timerLabel.setText("Done!");
                Toolkit.getDefaultToolkit().beep();

            }
        }
    }
    public static void main(String args[]) {
        CountdownTimer gui = new CountdownTimer();
        gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gui.setSize(250, 100);
        gui.setTitle("Timer Program");
        gui.setVisible(true);

    }

}

My task is to make a gui countdown timer for a speech contest. Please help me convert it into a gui wherein when the user creates a new "session". User should be able to input the speaker's name, duration of speech(this is where the code above comes in. The code I have pasted above is only a Second Timer please help me convert it into a Minute timer as well. example: 7:00 -> 6:59 -> 6:58 so on and so forth), the speech title and a drop down box with two values: formal speech/table topics). Lastly, user should also be able to save time to a file. I am really desperate for you help guys. Please do help me :( Please please

ehm ... who wrote the above code?
if you did, you managed to figure out how to create a Timer for one second. adjust that to one minute.
that would be step 1.

Hi there, thank you very much for the reply. I tried to convert it by changing

            timer = new Timer(1000, tc);

in line 49 to

            timer = new Timer(6000, tc);

since 1 minute is equal to 60 000 milliseconds.
I also changed the output of the gui so it can display both minute and second part. I've managed to make the "minute" part work. My gui's output is something like this:

7:

then it becomes:

6:

How do I do the "second part"?

Thank you very much.

Get count in seconds as it was earlier.

 timer = new Timer(1000, tc);

then divide it by 60 and show then display remainer as in seconds and quotient as minutes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.