LabeledSlider.java


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


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

// import java.awt.*;
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–2017, Robert Sedgewick and Kevin Wayne.
Last updated: Fri Oct 20 14:12:12 EDT 2017.