Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Dawing Circles
- Saher Akram
- */
- import javax.swing.JApplet;
- import java.awt.Graphics;
- import java.awt.Color;
- import javax.swing.JOptionPane;
- public class DrawCircle extends JApplet
- {
- // declare variables here
- boolean rightInput=true;
- int smallestRadius, largestRadius;
- private double animationPause = .05;
- public void paint (Graphics g )
- {
- while (rightInput)
- {
- smallestRadius=Integer.parseInt(
- JOptionPane.showInputDialog(null,"Please enter the smallest radius for"
- + " the cirlce"));
- largestRadius=Integer.parseInt(
- JOptionPane.showInputDialog(null, "Please enter the largest radius for"
- +" the cirlce"));
- if (smallestRadius<largestRadius)
- {
- rightInput=false;
- }
- else
- {
- rightInput=true;
- }
- }
- super.paint( g );
- for (int c=smallestRadius;c<=largestRadius;c++)
- {
- g.fillOval(0,0,
- c,c);
- Pause.wait( (double) animationPause );
- g.clearRect(0,0,getWidth(),getWidth());
- }
- g.fillOval(0,0,largestRadius,largestRadius);
- }
- }
Add Comment
Please, Sign In to add comment