Sliders, Progress Bars and Toolbars
Site Admin
· 11 Sep 2026
· 2 views
JSlider
A slider picks a value from a range. Listen to its change events to react:
JSlider volume = new JSlider(0, 100, 40);
volume.addChangeListener(e -> value.setText("Volume: " + volume.getValue()));
JProgressBar
Displays task progress. Set the value between its minimum and maximum:
JProgressBar bar = new JProgressBar(0, 100);
bar.setValue(65);
bar.setStringPainted(true);
JScrollPane
Provide scrolling for large components without manual work:
JTextArea big = new JTextArea(10, 30);
add(new JScrollPane(big));
JToolBar
A draggable strip of buttons for quick actions:
JToolBar tb = new JToolBar();
tb.add(new JButton("New"));
tb.add(new JButton("Open"));
tb.addSeparator();
tb.add(new JButton("Save"));

Key Points
- Sliders and progress bars rely on bounded range models.
- Wrap big components in JScrollPane to get scrollbars automatically.
- Toolbars group actions into a floatable strip.