01: package net.ar.webonswing.tutorial;
02:
03: import java.awt.*;
04: import java.awt.event.*;
05:
06: import javax.swing.*;
07:
08: public class SliderExample extends JDialog {
09: public SliderExample() {
10: final JSlider slider = new JSlider(SwingConstants.HORIZONTAL,
11: 1, 100, 20);
12: final JButton button = new JButton("submit");
13: button.addActionListener(new ActionListener() {
14: public void actionPerformed(ActionEvent e) {
15: button.setText(slider.getValue() + "");
16: }
17: });
18:
19: getContentPane().setLayout(new GridLayout(2, 1));
20: getContentPane().add(slider);
21: getContentPane().add(button);
22: Dimension dimension = new Dimension(200, 200);
23: getContentPane().setSize(dimension);
24: getRootPane().setSize(dimension);
25: }
26: }
|