//Toby Hsieh //Chapter 6, Exercise 4 //Manipulate filled oval import java.awt.*; import java.applet.Applet; import java.awt.event.*; public class ch6ex4 extends Applet implements AdjustmentListener { private Scrollbar bar1, bar2; private int xValue=50; private int yValue=100; public void init() { Label title1, title2; title1=new Label("Width:"); add(title1); bar1=new Scrollbar(Scrollbar.HORIZONTAL, 50, 1, 1, 201); add(bar1); bar1.addAdjustmentListener(this); title2=new Label(" Height:"); add(title2); bar2=new Scrollbar(Scrollbar.HORIZONTAL, 100, 1, 1, 201); add(bar2); bar2.addAdjustmentListener(this); } public void paint(Graphics g) { g.fillOval(50, 50, xValue, yValue); g.drawString("Width: "+xValue, 100, 270); g.drawString("Height: "+yValue, 100, 285); } public void adjustmentValueChanged(AdjustmentEvent e) { xValue=bar1.getValue(); yValue=bar2.getValue(); repaint(); } }