E
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class JSliderDemo
{
public static void main(String[] a)
{
JFrame frame = new JFrame("JSlider Demo");
Container c = frame.getContentPane();
c.setLayout( new FlowLayout() );
final JTextField text = new JTextField("A picture worth more than thousands words" );
text.setFont(new Font("Serif",Font.PLAIN,30));
text.setEditable(false);
final JSlider fontSizeSlider = new JSlider(SwingConstants.HORIZONTAL,0,45,30);
fontSizeSlider.setMajorTickSpacing(1);
fontSizeSlider.addChangeListener( new ChangeListener()
{
public void stateChanged(ChangeEvent ce)
{
int fontSize;
fontSize = fontSizeSlider.getValue();
text.setFont( new Font("Serif",Font.PLAIN,fontSize));
}
}
);
c.add(text);
c.add(fontSizeSlider);
frame.setSize(550,200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
good one
ReplyDeleteThank you sir for sharing this valuable knowledge..
ReplyDeleteit's more profitable to me...
changa post...:p