... javax.swing.SwingConstants; 8   import javax.swing.event.ChangeListener;
 9   import javax.swing.event.ChangeEvent;
10
11   public class SliderFrame extends JFrame
12   {
13     private final JSlider diameterJSlider; // slider to select diameter
14     private final OvalPanel myPanel; // panel to draw circle
15
16     // no-argument constructor
17     public SliderFrame()
18     {
19        super("Slider Demo");
20
21        myPanel = new OvalPanel(); // create panel to draw circle
22        myPanel.setBackground(Color.YELLOW);
23
24        // set up JSlider to control diameter value
25        diameterJSlider =
26           new JSlider(SwingConstants.HORIZONTAL, 0, 200, 10);
27    diameterJSlider.setMajorTickSpacing(10); // create tick every 10
28    diameterJSlider.setPaintTicks(true); // paint ticks on slider
29
30 ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.