PPT Slide
import javax.swing.*; import javax.swing.event.*;
import java.awt.*; import java.awt.event.*;
public class JSliderTest extends JFrame implements ChangeListener{
JSlider slider; JLabel label; JPanel panel;
super("Test of Change Events");
this.addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
slider = new JSlider(); panel = new JPanel();
label = new JLabel("Value: " + slider.getValue());
panel.add(label); panel.add(slider);
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(panel);
slider.addChangeListener(this);
public void stateChanged(ChangeEvent e){
label.setText("Value: " + slider.getValue());
public static void main (String arg[]){
new JSliderTest().show();