📄 qticker.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.container.QFrame;
import org.qui.manager.QItem;
public class QTicker extends QItem implements Runnable {
private String text = "";
private QFrame frame = null;
public QTicker(String text, QFrame frame) {
super(0, 0, frame.frm_Width, 20);
super.height = font.getHeight();
this.frame = frame;
this.text = text;
text_Recycle = text;
new Thread(this).start();
}
public void setText(String text) {
this.text = text;
text_Recycle = text;
}
public String getText() {
return text;
}
public String text_Recycle = "";
private Graphics gTemp = null;
private int step = 0;
public void paint(Graphics g) {
int[] clip=new int[4];
clip[0] = g.getClipX();
clip[1] = g.getClipY();
clip[2] = g.getClipWidth();
clip[3] = g.getClipHeight();
g.setClip(x + ui.offx, y + ui.offy, width+1 ,height+1);
if (gTemp == null) {
gTemp = g;
}
g.setColor(br, bg, bb);
g.fillRect(x + ui.offx, y + ui.offy, width, height);
g.setColor(fr, fg, fb);
g.drawString(text_Recycle, x + ui.offx, y + ui.offy, Graphics.LEFT | Graphics.TOP);
g.setClip(clip[0],clip[1],clip[2],clip[3]);
}
public void run() {
int cycle_num = 0, cycleLength = text.length();
while (true) {
cycle_num = (cycle_num + cycleLength + 1) % cycleLength;
text_Recycle = text.substring(cycle_num)
+ text.substring(0, cycle_num);
if (gTemp != null) {
step = (step + 3) % 2;
frame.repaint(x+ui.offx,y+ui.offy,width,height);
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -