E-mail Jan Hunt | ||||
| Sun's Java - Applets | ||||
Simple Java Applet·Buttons.java demonstrates an applet with some buttons. Clicking the Square button displays a square in the center of the applet, clicking the Circle button displays a circle, etc. This applet uses the JDK 1.1 ActionListener model to sense events. | ||||
Jan's Craps in Java·DiceDemo.java extends applet and uses the ActionListener, switches, a random number generator is behind the Roll Dice button, and I create my own class for the Die used in the craps game. | ||||
Applet to Calculate a Monthly Loan·MonthlyLoanPayment.java demonstrates an applet using the Layout Manager, text components, the getText() and setText() methods. | ||||
State Maps Applet·pics.java extends applet and uses the ItemListener, and two dropdown combo boxes. When the user chooses a state the image is updated and the cities for that state are loaded into the cities combo box. Clicking on a city puts location on the state map. A multi-dimensional array is used for the cities and getImage() is used for the graphics which is in the java.net library. | ||||
Simple Drawing Program·Draw.java demonstrates an applet with a "roll-your-own" toolbar and is a simple rubber-banding demonstration. Class variables x1, y1 hold the anchored button-down point, while x2, y2 hold the current mouse points. Use a state variable to track the drags in process through WAITING --> DRAGGING --> WAITING. When dragging, mouseDrag sets XOR drawing mode, then erases the last figure and draws the current one to give the rubberband effect. | ||||