📄 fancytitle.java
字号:
import java.applet.*;
import java.awt.*;
import java.net.*;
public class FancyTitle extends Applet implements Runnable
{
private Image BackImage,ForeImage;
private Image offI,virtualI;
private Graphics offG,virtualG;
private Thread thread = null;
private MediaTracker imageTracker;
private int height,width,X,Y;
public void init()
{
BackImage = getImage(getDocumentBase(),"Back.jpg");
ForeImage = getImage(getDocumentBase(),"Fore.gif");
imageTracker = new MediaTracker(this);
imageTracker.addImage(BackImage,0);
imageTracker.addImage(ForeImage,0);
width = this.size().width;
height = this.size().height;
try
{
imageTracker.waitForID(0);
}
catch(InterruptedException e){}
offI = createImage(width,height);
offG = offI.getGraphics();
virtualI=createImage(width*2,height*2);
virtualG=virtualI.getGraphics();
}
public void start()
{
if(thread == null)
{
thread = new Thread(this);
thread.start();
}
}
public void run()
{
int x= 0, y=0;
int tileWidth = BackImage.getWidth(this);
int tileHeight = BackImage.getHeight(this);
while(thread != null)
{
try
{
thread.sleep(0);
x=virtualI.getWidth(this)-width;
y=virtualI.getHeight(this)-height;
for(;(x>0)&&(y>0); x--,y--)
{
if((x==0)||(y==0))
{
x=virtualI.getWidth(this)-width;
y=virtualI.getHeight(this)-height;
}
for(int j=0; j < virtualI.getHeight(this); j = j + tileHeight)
for(int i=0; i < virtualI.getWidth(this); i = i + tileWidth)
virtualG.drawImage(BackImage, i, j, this);
virtualG.drawImage(ForeImage, x, y,width,height,this);
offG.drawImage(virtualI,-x,-y,this);
repaint();
}
}
catch(InterruptedException e){}
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(offI,0,0,this);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -