rendered paste bodyimport java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Timer;
public class Test
{
public float Ptr;
public boolean Boo1;
public Test()
{
face();
Ptr = 00.0f;
Boo1 = true;
}
public void run()
{
while (Ptr <= 99.9f && Boo1 == true)
{
Ptr += 0.1f;
try {
Thread.sleep(1000);
//1000 millisecs
}
catch(InterruptedException ex) {
}
}
}
public void stop()
{
Boo1 = false;
}
public void face()
{
JFrame frame = new JFrame("button");
Container contentPane = frame.getContentPane();
JPanel buttonPanel = new JPanel();
JButton button2 = new JButton("Run");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { run();
} });
buttonPanel.add(button2);
contentPane.add(buttonPanel);
JButton button1 = new JButton("stop");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { stop();
} });
buttonPanel.add(button1);
contentPane.add(buttonPanel);
frame.pack();
frame.setVisible(true);
}
}