LabeledSlider.java


Below is the syntax highlighted version of LabeledSlider.java from §3.6 Case Study: Purple America.


/******************************************************************************
 *  Compilation:  javac LabeledSlider.java
 *
 ******************************************************************************/

import javax.swing.JSlider;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;

public class LabeledSlider extends JSlider {
    private TitledBorder border = new TitledBorder(new EtchedBorder());

    public LabeledSlider(int min, int max, int val) {
        super(min, max, val);
        setBorder(border);
    }

    public void setLabel(String s) {
        border.setTitle(s);
    }
}


Copyright © 2000–2022, Robert Sedgewick and Kevin Wayne.
Last updated: Sun Dec 11 15:45:41 EST 2022.