📄 qtextfield.java
字号:
/**
* 作者:cat 戚永城
* 时间:2008-3-1
* QQ:415898635
* E-Mail: 415898635@qq.com
* qyc_12345@163.com
*
* */
package org.qui.conmponent;
import javax.microedition.lcdui.Graphics;
import org.qui.image.JiugongDiv;
import org.qui.info.Attribute;
import org.qui.manager.QInputItem;
import org.qui.manager.UIManager;
public class QTextField extends QInputItem {
public QTextField(){
super();
}
public QTextField(int x, int y, int width, int height) {
super(x, y, width, height);
fr=Attribute.text_foreR;
fg=Attribute.text_foreG;
fb=Attribute.text_foreB;
}
public void paint(Graphics g) {
// 画背景
if (focus) {
JiugongDiv.drawJiuGong(g, UIManager.text_focus, x + ui.offx, y + ui.offy, width, height);
} else {
JiugongDiv.drawJiuGong(g, UIManager.text_normal, x + ui.offx, y + ui.offy, width, height);
}
// 画label 缩减5像素
g.setColor(fr, fg, fb);
g.setFont(font);
if (font.stringWidth(text) > width) {
int length=text.length();
int charsWidth=0;
for(int i=length-1;i>=0;i--){
charsWidth=charsWidth+font.charWidth(text.charAt(i));
if(charsWidth<width-10)
g.drawChar(text.charAt(i), x + ui.offx + width - 6-charsWidth, y + ui.offy + height - 1,Graphics.LEFT| Graphics.BOTTOM);
else
break;
}
} else {
g.drawString(text, x + ui.offx + 6, y + ui.offy + height - 1, Graphics.LEFT| Graphics.BOTTOM);
}
super.paint(g);
}
public void keyPressed(int keyCode) {
super.keyPressed(keyCode);
}
public void keyReleased(int keyCode) {
super.keyReleased(keyCode);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -