Set JSlider Client Properties: JSlider.isFilled in Java

Description

The following code shows how to set JSlider Client Properties: JSlider.isFilled.

You can enable a client property that signals the slider to fill this track up to the point of the current value that the thumb has crossed. The name of this property is JSlider.isFilled, and a Boolean object represents the current setting.

Example


/*  ww w .  j av a2s. co  m*/
 
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JSlider;

public class Main {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Tick Slider");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSlider oneJSlider = new JSlider();
    oneJSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
    JSlider anotherJSlider = new JSlider();
    // Set to default setting
    anotherJSlider.putClientProperty("JSlider.isFilled", Boolean.FALSE);

    frame.add(oneJSlider, BorderLayout.NORTH);
    frame.add(anotherJSlider, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}

The code above generates the following result.

Set JSlider Client Properties: JSlider.isFilled in Java




















Home »
  Java Tutorial »
    Swing »




Action
Border
Color Chooser
Drag and Drop
Event
Font Chooser
JButton
JCheckBox
JComboBox
JDialog
JEditorPane
JFileChooser
JFormattedText
JFrame
JLabel
JList
JOptionPane
JPasswordField
JProgressBar
JRadioButton
JScrollBar
JScrollPane
JSeparator
JSlider
JSpinner
JSplitPane
JTabbedPane
JTable
JTextArea
JTextField
JTextPane
JToggleButton
JToolTip
JTree
Layout
Menu
Timer