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()));
                }
 
 

}

4 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

Sandeep SEO said...

Thank you for sharing this useful story. I think you shared the information is helpful to me and useful........................Please contact us for Oracle Fusion Financials Training details in our Erptree Training Institute

Unknown said...

good nice
http://spunksoft.com/course/sap-s4-hana-simple-finance-training-in-hyderabad/

Unknown said...

Such as very good information promoting content are provided and more skills are improved after referring to that post.
Oracle Fusion SCM Training in Hyderabad

Post a Comment