★★ Java の宿題ここで答えます Part 55 ★★
■ このスレッドは過去ログ倉庫に格納されています
0038デフォルトの名無しさん
2006/01/27(金) 22:52:52public class Sample extends Applet implements ActionListener{
TextField text;
Image img[][] = new Image[3][3];
boolean ch=false;
public void init(){
setLayout(null);
text = new TextField();
text.addActionListener(this);
add(text);
text.setBounds(10,20,200,20);
}
public void paint(Graphics g){
if(ch==true){
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
g.drawImage(img[i][j],i*100,j*100+100,100,100,this);
}
}
public void actionPerformed(ActionEvent e){
if(text.getText().equals("")==false){
String str = text.getText();
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
img[i][j] = getImage(getDocumentBase(),str.charAt(i*3+j)+".gif");
ch=true;
text.setText(null);
repaint();
}
}
}
■ このスレッドは過去ログ倉庫に格納されています