Guest User

Untitled

a guest
May 23rd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. /*Dawing Circles
  2. Saher Akram
  3. */
  4.  
  5. import javax.swing.JApplet;
  6. import java.awt.Graphics;
  7. import java.awt.Color;
  8. import javax.swing.JOptionPane;
  9.  
  10. public class DrawCircle extends JApplet
  11. {
  12.  
  13. // declare variables here
  14. boolean rightInput=true;
  15. int smallestRadius, largestRadius;
  16. private double animationPause = .05;
  17.  
  18. public void paint (Graphics g )
  19. {
  20. while (rightInput)
  21. {
  22. smallestRadius=Integer.parseInt(
  23. JOptionPane.showInputDialog(null,"Please enter the smallest radius for"
  24. + " the cirlce"));
  25.  
  26. largestRadius=Integer.parseInt(
  27. JOptionPane.showInputDialog(null, "Please enter the largest radius for"
  28. +" the cirlce"));
  29.  
  30. if (smallestRadius<largestRadius)
  31. {
  32. rightInput=false;
  33. }
  34. else
  35. {
  36. rightInput=true;
  37. }
  38. }
  39.  
  40. super.paint( g );
  41.  
  42. for (int c=smallestRadius;c<=largestRadius;c++)
  43. {
  44. g.fillOval(0,0,
  45. c,c);
  46. Pause.wait( (double) animationPause );
  47.  
  48. g.clearRect(0,0,getWidth(),getWidth());
  49.  
  50. }
  51. g.fillOval(0,0,largestRadius,largestRadius);
  52.  
  53. }
  54. }
Add Comment
Please, Sign In to add comment