Search This Blog

Tuesday, November 23, 2010

ScrollBar in Swing to increase font size

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;



public class ScrollFont extends JApplet implements AdjustmentListener
  {
  
/*<Applet code="ScrollFont.class" height=200 width=400>
   </Applet>
*/

JLabel lbl;
JScrollBar bar;
public void init()
  {
  
  
     Container frame = getContentPane();    
        lbl = new JLabel("  Welcome to My Blog");
        lbl.setForeground(Color.blue);
        frame.setLayout(new BorderLayout());
        bar=new JScrollBar(0,7,5,7,50);
        bar.setToolTipText("Scroll to increase font size");      
        bar.addAdjustmentListener(this);
        frame.add(lbl, BorderLayout.CENTER);
        frame.add(bar,BorderLayout.NORTH);  

    
   }          
                public void adjustmentValueChanged(AdjustmentEvent e)
                 {
                
                  lbl.setFont(new Font("Helvetica", Font.BOLD,bar.getValue()));
                }
 
 

}

1 comments:

geetha said...

Ecorptrainings.com provides JAVA SWING in hyderabad with best faculties on real time projects. We give the best online trainingamong the JAVA SWING in Hyderabad. Classroom Training in Hyderabad India

Post a Comment