📄 album.java
字号:
import java.awt.*;
import java.applet.*;
import java.io.*;
public class Album extends Applet
{
private Choice C1;
private String S1[],S2[];
private int totalPics;
private Image offI,img[];
private Graphics offG;
private MediaTracker imagetracker;
public void init()
{
this.setLayout(null);
C1 = new Choice();
C1.setBounds(10,10,290,20);
totalPics = Integer.parseInt(getParameter("TotalPic"));
System.out.println(totalPics);
S1 = new String[totalPics];
S2 = new String[totalPics];
img = new Image[totalPics];
for(int i=0; i<totalPics; i++)
{
S1[i] = new String("");
S2[i] = new String("");
}
String s = new String("");
imagetracker = new MediaTracker(this);
for(int i=0; i<totalPics; i++)
{
s = getParameter("Text" + (i+1));
S1[i] = s;
System.out.println(S1[i]);
C1.addItem(s);
s = getParameter("Picture" + (i+1));
S2[i] = s;
img[i] = getImage(getDocumentBase(), s);
imagetracker.addImage(img[i],0);
System.out.println(S2[i]);
}
try
{
imagetracker.waitForID(0);
}
catch(InterruptedException e)
{
}
add(C1);
offI = createImage(size().width,size().height-40);
offG = offI.getGraphics();
}
public void paint(Graphics g)
{
g.drawImage(offI,10,40,this);
}
public boolean action(Event e , Object o)
{
if(e.target == C1)
{
String s = new String("");
offG.setColor(this.getBackground());
offG.fillRect(0,40,size().width,size().height-40);
offI = img[C1.getSelectedIndex()];
offG.drawImage(offI,0,0,this);
repaint();
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -