showtitlethread.java.bak
来自「经典的java applet小程序下来看看说不定有启发哦」· BAK 代码 · 共 100 行
BAK
100 行
import java.awt.*;import java.applet.*;import java.util.*;public class showTitleThread extends Applet { public Image offImage;public Graphics offGraphics;public Dimension offDimension;String title,fill;int delayTime;int pos , blinkWidth;int x=800;Thread thisThread;Font myFont=new Font("TimesRoman",Font.BOLD,48);public void init(){title="Welcome you to come here!"; fill="";delayTime=10;pos=0;blinkWidth=150;}public void start(){if(thisThread==null){thisThread=new mythread(); thisThread.start();}}public void stop(){ thisThread=null; offImage=null; offGraphics=null; }class mythread extends Thread{public void run(){ while(thisThread!=null) { repaint(); try{ Thread.sleep(30); }catch(InterruptedException e){ break;} }//while}//run}public void update(Graphics g){ Dimension d=getSize(); if((offGraphics==null)||(d.width!=offDimension.width)||(d.height!=offDimension.height)) { offDimension=d; offImage=createImage(d.width,d.height); offGraphics=offImage.getGraphics(); } offGraphics.setColor(getBackground()); offGraphics.fillRect(0,0,d.width,d.height); FontMetrics myFM=g.getFontMetrics(myFont); int height=myFM.getHeight(); int top=myFM.getAscent(); offGraphics.setFont(myFont); if(x>-500) { x=(x-1)%getSize().width; } else { x=1000; } offGraphics.setColor(Color.red); offGraphics.drawString(title,x,top); g.drawImage(offImage, 0,0, this); paint(g);}public void paint(Graphics g){ if(offImage!=null) { g.drawImage(offImage, 0, 0, this); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?