source: src/main/java/genius/gui/uncertainty/SteppingSliderExample.java@ 346

Last change on this file since 346 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.5 KB
Line 
1package genius.gui.uncertainty;
2import javax.swing.BoxLayout;
3import javax.swing.JFrame;
4import javax.swing.JLabel;
5import javax.swing.SwingUtilities;
6import javax.swing.event.ChangeEvent;
7import javax.swing.event.ChangeListener;
8
9public class SteppingSliderExample
10{
11
12 public static void createAndShowGUI()
13 {
14 JFrame frame = new JFrame("SteppingSlider");
15 frame.setSize(500, 120);
16 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
17 final SteppingSlider steppingSlider = new SteppingSlider(10, 20, 50, 100);
18 final String labelPrefix = "Slider value: ";
19 final JLabel output = new JLabel(labelPrefix + steppingSlider.getDomainValue());
20 steppingSlider.addChangeListener(new ChangeListener()
21 {
22 @Override
23 public void stateChanged(ChangeEvent evt)
24 {
25 output.setText(labelPrefix + steppingSlider.getDomainValue());
26 }
27 });
28 frame.getContentPane().setLayout(
29 new BoxLayout(frame.getContentPane(),
30 BoxLayout.Y_AXIS));
31 frame.getContentPane().add(steppingSlider);
32 frame.getContentPane().add(output);
33 frame.setVisible(true);
34 }
35
36 public static void main(String[] args) throws Exception
37 {
38 SwingUtilities.invokeLater(new Runnable()
39 {
40 public void run()
41 {
42 createAndShowGUI();
43 }
44 });
45 }
46}
Note: See TracBrowser for help on using the repository browser.