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 »
- Would-be Japanese space tourist wants $21M back
- NASA scales back flagship Mars mission
- Bulgarian archaeologists unearth ancient chariot
- Witnesses: Large meteor streaks across Canada sky
- Solar panels on graves give power to Spanish town
- Fuel from food? The feast is over
- Fabulous flippers: Dolphins have quite the kick
- Whales rescued from Australian beach join pod
- Siberian quake triggers false US seismic reports
- Pirates sign Indian _ not Cleveland _ pitchers

