source file name: SliderDemo.java
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
public class SliderDemo extends JFrame implements ChangeListener
{
JSlider sd;
JLabel lb;
public SliderDemo()
{
setLayout(new BorderLayout());
sd=new JSlider(0,100);
lb=new JLabel("WEL-COME");
sd.setValue(10);
sd.setMinorTickSpacing(5);
sd.setMajorTickSpacing(10);
sd.setPaintLabels(true);
sd.setPaintTicks(true);
add(lb,BorderLayout.NORTH);
add(sd,BorderLayout.CENTER);
sd.addChangeListener(this);
}
public void stateChanged(ChangeEvent ce)
{
int n=sd.getValue();
Font ft=new Font("French Script MT",Font.BOLD,n);
lb.setFont(ft);
}
public static void main(String[] args)
{
SliderDemo f=new SliderDemo();
f.setSize(500,500);
f.setVisible(true);
}
}
output:
0 Comments
Post a Comment