Use fonts and colors in J2ME phone programming

Source: Internet
Author: User
Tags int size first row

Using fonts

In J2ME mobile programming, you can use the Font class--font in the low-level user interface to achieve better performance, then how to use the Font class?

First of all, due to the limitations of mobile devices, the type of font supported in mobile phones is limited, so the font class object can only be constructed using the default font supported by the mobile phone in J2ME. The following are the methods to use when creating objects for the Font class:

GetFont (int face,int style,int size);

For example:

Font font = Font.getfont (font.face_system,font.style_bold,font. Size_medium);

Regardless of which parameter, you can use only the values that are set by the system, which can vary in size from one phone to another. The following is a detailed description of the values of the three parameters:

The face parameter refers to the appearance of the font and its value:

face_monospace--Equal width font

face_proportional--Balanced Fonts

face_system--system fonts

The style parameter refers to the type of the font, and its value:

style_bold--Bold

style_italic--Oblique Body

style_plain--Ordinary

style_underlined--Underline

Style_bold | style_italic--Bold Italic

style_underlined | style_bold--underlined Bold

style_underlined | style_italic--underlined italic

style_underlined | Style_italic | style_bold--Bold Italic with underlined

The size parameter refers to the sizes of the fonts and their values:

size_small--Small

In size_medium--

size_large--Big

By the value of the above parameter, you can assemble the Font object you want.

Here are some common font actions:

1. Get the default font for the system:

Font font = Font.getdefaultfont ();

2. Within the Panit method, assuming the name of the graphics parameter is G, the method for obtaining the current font is:

Font font = G.getfont ();

3. Within the Panit method, assuming the name of the graphics parameter is g, the current font method is set:

G.setfont (font);

The Font object that font constructs for you.

4. In MIDP2.0, the list can set the font format for each row by:

List.setfont (0,font);

The code above is to set the first row in the list to the font type.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.