📄 qpasswordfield.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 QPasswordField extends QInputItem {
public QPasswordField(){
super();
}
public QPasswordField(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 char passShow = '*';
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);
int chrWidth = font.charWidth(passShow);
int length = text.length();
int maxChars=(width-10)/chrWidth;
if (chrWidth * length > width) {
for (int i = 0; i < maxChars; i++) {
g.drawChar(passShow, x + ui.offx + width - 6 - i * chrWidth, y + ui.offy + height - 1, Graphics.RIGHT | Graphics.BOTTOM);
}
} else {
for (int i = 0; i < length; i++) {
g.drawChar(passShow, x + ui.offx + 6 + i * chrWidth, 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 + -