Use color in J2ME mobile program development

Source: Internet
Author: User
Tags format expression getcolor
Program in the J2ME mobile phone development process, the need to often use color to draw, enhance the performance of the program, the following describes how to use color.       because the J2ME technology is relatively simple, it does not implement a special color class, but only uses the concept of RGB to represent color. Here is a brief introduction to the concept of RGB, color is made of red, green (blue), the three primary colors, so you can use the combination of these three colors to represent a specific color, where r, G, B, each value is located between 0-255. When the color is expressed, it can be expressed in three digits, or it can be expressed in a hexadecimal format such as 0X00RRGGBB, which is the expression of a common color:       red: ( 255,0,0) or 0x00ff0000       green: (0,255,0) or 0x0000ff00        White: (255,255,255) or 0x00ffffff       other colors can also be combined in the above way.        know the color of the expression, the following describes how to use color in the J2ME program, the methods involved in the graphics class, there are several:1.          GetColor (): Gets the color currently in use and the return value is a number in 0X00RRGGBB format. For example: int color = G.getcolor (), where G is an object of type graphics. 2.         setcolor (int RGB): Sets the color used. For example: G.setcolor (0x00ff0000);3.         setcolor (int red, int green, int blue) As in the above method, for example: G.setcolor (255,0,0);        when you set the color used by graphics and then draw it, you can draw the specified color.


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.