All pastes #975491 Raw Edit

Someone

public text v1 · immutable
·published 2008-04-07 16:29 UTC
rendered paste body
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Timer;

class Run extends Thread
{
  public Run()
  {}
  
  public void run()
  {
    while (MainThread.Ptr <= 99.9f && MainThread.Boo1 == true)
             {
                 MainThread.Ptr += 0.1f;
              try {
                   Thread.sleep(1000);
                   
                   //1000 millisecs
                  }
              catch(InterruptedException ex) {
                  }  
             }   
     }
    }       

class Stop extends Thread
{
    public Stop()
    {}
    public void run()
    {
        MainThread.Boo1 = false;
    }
}



public class MainThread
{
public static float Ptr;
public static boolean Boo1;
public JFrame PtrFrame;
public JPanel inputPanel;

   public MainThread()
   { 
      Ptr = 00.0f;
      Boo1 = true;
      main();
      openPpFrame();
    }
    
    public static void main()
    {
       Thread thread1 = new Thread(new Run());
	   Thread thread2 = new Thread(new Stop());
	   thread1.start();
	   thread2.start();
	   
    }
		
    public void openPpFrame()
   {
     
     PtrFrame = new JFrame("Ptr");
  
     //Creates a container and assigns it to the frame..
     Container ppPane = PtrFrame.getContentPane();
     
     inputPanel = new JPanel();
     
     JButton ppButton = new JButton("Pp");
     ppButton.addActionListener(new ActionListener() 
     {
         public void actionPerformed(ActionEvent e) 
         { 
              thread1.run();                 
         } 
        });  
     inputPanel.add(ppButton);
     ppPane.add(inputPanel);
     
      JButton stopButton = new JButton("Stop Pp");
     stopButton.addActionListener(new ActionListener() 
     {
         public void actionPerformed(ActionEvent e) 
         { 
           thread2.run();  
          } 
     }); 
     inputPanel.add(stopButton);
     ppPane.add(inputPanel);
        
     ppPane.add(inputPanel);
     PtrFrame.pack();
     //Sets the interface to visible..
     PtrFrame.setVisible(true);
   }
   
}