How to display rotated text in Java ME

This article provides a method for displaying rotated text on a canvas in [[Java ME]]. The idea is to create an empty image, write the text on it and display it, rotated.

<code java>
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.Sprite;

public class MyCanvas extends Canvas { public void paint(Graphics g) { //The text that will be displayed String s=”java”; //Create the blank image, specifying its size Image img=Image.createImage(50,50); //Create an instance of the image’s Graphics class and draw the string to it Graphics gr=img.getGraphics(); gr.drawString(s, 0, 0, Graphics.TOP|Graphics.LEFT); //Display the image, specifying the rotation value. For example, 90 degrees g.drawRegion(img, 0, 0, 50, 50, Sprite.TRANS_ROT90, 0, 0, Graphics.TOP|Graphics.LEFT); }
}
</code>

Screenshot:

[[Image:Rotated_text.JPG]]



Thank you for reading this post. You can now Leave A Comment (0) or Leave A Trackback.

Post Info

This entry was posted on Sunday, September 7th, 2008 and is filed under Insurance.

You can follow any responses to this entry through the Comments Feed. You can Leave A Comment, or A Trackback.



Previous Post: Nokia: Q3 2008 market share may drop »
Next Post: Pixelmator puts new shortcuts in 1.2.3, pitches 1.3 Tempo beta »

Read More

Related Reading:



Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.

You must be logged in to post a comment.

How to display rotated text in Java ME

This article provides a method for displaying rotated text on a canvas in Java ME. The idea is to create an empty image, write the text on it and display it, rotated.

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.Sprite;
 
public class MyCanvas extends Canvas {

public void paint(Graphics g) {
//The text that will be displayed
String s="java";
//Create the blank image, specifying its size
Image img=Image.createImage(50,50);
//Create an instance of the image’s Graphics class and draw the string to it
Graphics gr=img.getGraphics();
gr.drawString(s, 0, 0, Graphics.TOP|Graphics.LEFT);
//Display the image, specifying the rotation value. For example, 90 degrees
g.drawRegion(img, 0, 0, 50, 50, Sprite.TRANS_ROT90, 0, 0, Graphics.TOP|Graphics.LEFT);
}

}

Screenshot:



Thank you for reading this post. You can now Leave A Comment (0) or Leave A Trackback.

Post Info

This entry was posted on Sunday, September 7th, 2008 and is filed under Blogroll.

You can follow any responses to this entry through the Comments Feed. You can Leave A Comment, or A Trackback.



Previous Post: Israeli diggers uncover parts of ancient wall »
Next Post: TSS001089 - Canceling an asynchronous silent uninstallation takes a long time »

Read More

Related Reading:



Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.

You must be logged in to post a comment.

edwan