home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-03-22 | 1.7 KB | 69 lines |
- import java.awt.*;
- import java.applet.*;
-
- /**
- * ArcApplet demonstrates drawing arcs by enabling the user
- * to input the arc's parameters.
- *
- * @version 1.0, 1/15/96
- * @author Clayton Walnum
- */
- public class ArcApplet extends Applet
- {
- TextField textField1, textField2;
-
- /**
- * Creates the applet's textfield controls and adds
- * the controls to the applet's display.
- *
- * @return None
- */
- public void init()
- {
- textField1 = new TextField(10);
- textField2 = new TextField(10);
-
- add(textField1);
- add(textField2);
-
- textField1.setText("0");
- textField2.setText("360");
- }
-
- /**
- * Retrieves the user-defined parameters from the text
- * boxes, converts them to integers, and uses them
- * to display an arc.
- *
- * @return None
- * @param g The applet's Graphics object
- * @see #action
- */
- public void paint(Graphics g)
- {
- String s = textField1.getText();
- int start = Integer.parseInt(s);
-
- s = textField2.getText();
- int sweep = Integer.parseInt(s);
-
- g.drawArc(35, 50, 125, 180, start, sweep);
- }
-
- /**
- * Responds when the user presses Enter from one of the
- * applet's text boxes. Calls repaint() to force the applet
- * to redraw its display with the new parameters.
- *
- * @return A boolean value indicating whether the
- * event was handled.
- * @param event The action's event object
- * @param arg Event-dependent information
- */
- public boolean action(Event event, Object arg)
- {
- repaint();
- return true;
- }
- }
-