📄 bqtickerbar.java
字号:
/*
* Created on 2005-9-20 by pcy
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package a.a.a.midp.lcdui;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JPanel;
import java.awt.*;
public class BQTickerBar extends JPanel {
public static final long serialVersionUID=1;
static final int TICK_RATE = 250;
private Timer timer;
private BQTicker ticker;
private String tickerString;
private Color bkColor;
private int x;
private int y;
private int width;
private int height;
private int tickSpeed;
private int tickWidth;
boolean hasTicker;
Stroke stroke;
public BQTickerBar() {
super();
float[] dashP = new float[1];
dashP[0] = 2;
stroke=new BasicStroke(1.0F,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0F, dashP,
0);
dashP=null;
bkColor=new Color(255,255,255);
y=3;
}
public BQTicker getTicker(){
return ticker;
}
public void setTicker(BQTicker ticker){
this.ticker=ticker;
if(ticker==null){
hasTicker=false;
return;
}else{
x=0;
hasTicker=true;
if(timer==null){
timer=new Timer();
timer.schedule(new TimerTask(){
public void run(){
x=(x<=-tickWidth)?width:x-tickSpeed;
repaint();
}
}, TICK_RATE);
}
tickerString=ticker.getString();
tickSpeed=ticker.getTickSpeed();
tickWidth=ticker.getTickWidth();
width=this.getWidth();
height=this.getHeight();
}
}
public void resizeScreen(){
}
protected void paintComponent(Graphics graph){
if(hasTicker){
graph.setColor(bkColor);
graph.fillRect(0,0,width,height);
graph.drawString(tickerString,x,y);
Stroke s=((Graphics2D) graph).getStroke();
((Graphics2D) graph).setStroke(stroke);
graph.drawLine(0,0,width,0);
graph.drawLine(0,height,width,height);
((Graphics2D) graph).setStroke(s);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -