Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Different Size of Font MIDlet Example 
 

This example simply shows the different size of font. There are three attributes are used for the different font sizes.

 

Different Size of Font MIDlet Example

                         

This example simply shows the different size of font. There are three attributes are used for the different font sizes. That are:

  • Font.SIZE_LARGE);

  • Font.SIZE_MEDIUM);  

  • Font.SIZE_SMALL);   

The SIZE_LARGE is used to large size of font, the SIZE_MEDIUM is used to medium size of font and the SIZE_SMALL is used to small size of font, which shows in the mobile figure below:

 

 

Source Code of FontSize.java

 

import java.io.*;
import java.lang.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;  

public class FontSize extends MIDlet {
  public static final boolean COLOR = false;
  public static final boolean DEBUG = false;
  private Display display = null;
  private FontCanvas fontCanvas = null;
  private boolean painting = false;

  public FontSize() {        
    display = Display.getDisplay(this);
        fontCanvas = new FontCanvas(this);
  }

  public void startApp() throws MIDletStateChangeException 
    display.setCurrent(fontCanvas);
  }

  public void pauseApp() {}

  protected void destroyApp(boolean unconditionalthrows 
                                 MIDletStateChangeException {}

  class FontCanvas extends Canvas {
    private FontSize parent = null;
    private int width = getWidth();
        private int height = getHeight();

    public FontCanvas(FontSize parent) {
      this.parent = parent;
    }

    public void paint(Graphics g) {
      g.setColor(2551280);  
            g.fillRect(00, width, height);
            Font font1 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, 
            Font.SIZE_LARGE
);  

            Font font2 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, 
            Font.SIZE_MEDIUM
);  

            Font font3 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, 
            Font.SIZE_SMALL
);  

            int position = 0;
            if(COLOR){
                g.setColor(255255255);       
            }else
                g.setColor(192192192);            
        g.fillRect(0, position, width, font1.getHeight());
      }
            if(COLOR){
                g.setColor(255255255);       
            }else{
                g.setColor(000);
      }
      g.setFont(font1);
            g.drawString("LARGE SIZE FONT"0, position, Graphics.LEFT | 
            Graphics.TOP
);

      position = position + font1.getHeight() 10;
            g.setFont(font2);
        g.drawString("MEDIUM SIZE FONT"0, position, Graphics.LEFT | 
        Graphics.TOP
);
            g.setColor(000);       
            position = position + font1.getHeight() 10;            
            g.setFont(font3);
            g.drawString("SMALL SIZE FONT"0, position, Graphics.LEFT | 
            Graphics.TOP
);
      position = position + font1.getHeight() 10;
      g.drawLine(0, font3.getHeight() + position - 1, width, font3.getHeight() 
      + position - 
1);
      painting = false;
    }
  }
}

Download Source Code

                         

» View all related tutorials
Related Tags: c io vi lock this block set frame example ram exam locks e il manual blocks man in as m

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.