-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slider.java
37 lines (31 loc) · 817 Bytes
/
Slider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.awt.event.*;
import javax.swing.*;
public class Slider extends JFrame{
public Slider() {
super("Slider");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLookAndFeel();
JSlider pickNum = new JSlider(JSlider.HORIZONTAL, 0, 30, 5);
pickNum.setMajorTickSpacing(10);
pickNum.setMinorTickSpacing(1);
pickNum.setPaintTicks(true);
pickNum.setPaintLabels(true);
add(pickNum);
pack();
setVisible(true);
}
private void setLookAndFeel () {
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
);
SwingUtilities.updateComponentTreeUI(this);
}catch (Exception e){
System.out.println("Couldn't use the system "
+ "look andfeel: " + e);
}
}
public static void main(String[] args) {
Slider frame = new Slider();
}
}