JAVA : How do I reduce the timer's time when the timer is running?
<h2>Question</h2>

<p>I want to make everytime i input the wrong answer the time reducing and i have more panel like this, i want to make when i move to next panel the time start, not when i compile the file the timer start the same time.</p>

<h2>Output</h2>

<p><a href="https://i.stack.imgur.com/Pn0UM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pn0UM.jpg" alt="enter image description here"></a></p>

<h2>Code</h2>

<pre><code>    int time = 7000;
    ans2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
                if(ans2.getText().toUpperCase().equals("CAT")){
                    word.setText("CAT");
                    ans2.setText("");
                    if(word.getText().equals("CAT") &amp;&amp; word2.getText().equals("CARD") &amp;&amp; word3.getText().equals("TILES") &amp;&amp; word4.getText().equals("MIRROR") &amp;&amp; word5.getText().equals("COUCH") &amp;&amp; word6.getText().equals("STRAW")){
                        JOptionPane.showMessageDialog(null, "COMPLETE\n Go to Next Stage");
                        word.setText(""); word2.setText(""); word3.setText(""); word4.setText(""); word5.setText(""); word6.setText("");
                        timer.stop();
                        CardLayout cl = (CardLayout) main.getLayout();
                        cl.show(main, "Stage2");
                    }
                }
                //i want to make "else if wrong answer time reduce 2 sec"
            }
        });
    JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 70);
    progressBar.setValue(70);
    progressBar.setPreferredSize(new Dimension(600, 20));
    ActionListener listener = new ActionListener() {    
        int counter = 70;
        public void actionPerformed(ActionEvent ae) {
            counter--;
            progressBar.setValue(counter);
            if (counter&lt;1) {
                JOptionPane.showMessageDialog(null, "Game Over!");
                timer.stop();
                CardLayout cl = (CardLayout) main.getLayout();
                cl.show(main, "Main Menu");
            } 
        }
    };
    timer = new Timer(time, listener);
    timer.start();// i have main menu and i want the timer start when i press start button in main menu 
</code></pre>