How to use freely resizable font in in Java ME(2)
else Display.getDisplay(this).setCurrent(alert);
}
}
[edit]
Source code: FontCanvas.java
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import com.nokia.mid.ui.DirectUtils;
import com.nokia.mid.ui.TactileFeedback;
public class FontCanvas extends Canvas implements CommandListener {
private FontSizingMIDlet midlet;
private Command exitCommand;
private String heightString = "";
private String fontString = "";
private Font font;
private int fontHeight = 20;
private int buttonFontHeight = 20;
private int face = 0;
private int style = 0;
private int edge = 0;
private int width;
private int height;
private TactileFeedback tactileFeedback;
private boolean touchFeedback = false;
private Button plusButton;
private Button minusButton;
private Button styleButton;
private boolean init = false;
public FontCanvas(FontSizingMIDlet midlet) {
this.midlet = midlet;
exitCommand = new Command("Exit", Command.EXIT, 1);
this.addCommand(exitCommand);
this.setCommandListener(this);
tactileFeedback = new TactileFeedback();
touchFeedback = tactileFeedback.isTouchFeedbackSupported();
}
public void paint(Graphics g) {
if (!init) {
width = getWidth();
height = getHeight();
plusButton = new Button(60, 25, "HEIGHT+");
minusButton = new Button(60, 25, "HEIGHT-");
styleButton = new Button(60, 25, "STYLE");
}
heightString = "Font height = " + fontHeight;
fontString = "Style = " + style + ", face = " + face;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>