Hot 15 Update

2024-01-22 2023-09-17 2023-05-21 2023-02-17 2022-12-02 2022-11-27 2022-11-26 2022-10-07 2022-10-03

topJava教室 ≫ 画像を表示する 更新: 2021.01.21 (1197d)

画像を表示する




<html>
<body>
<applet code= "sample.class" width="100" height="200">
</applet>
</body>
</html>

<applet code= "sample.class" width="100" height="200">


import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.applet.*;
import java.awt.*;

public class sample extends Applet
{
    Image img[] = new Image[1];
    
    public void init()          // 画像の読み込み
    {
        img[0] = getImage(getDocumentBase(), "sample.gif");
    }
    
    public void paint(Graphics g) // 画像表示
    {
        g.drawImage( img[0],1,1, this );
    }
}


img[0] = getImage(getDocumentBase(), "sample.gif");

g.drawImage( img[0],1,1, this );



img[0] = getImage(getDocumentBase(), "sample.gif");
 ↓ ↓
img = getImage(getDocumentBase(), "sample.gif");
g.drawImage( img[0],1,1, this );
 ↓ ↓
g.drawImage( img,1,1, this );






import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.applet.*;
import java.awt.*;

public class puzzle extends Applet
{
    Image img[] = new Image[4]; //sampleでは[1]でしたが,画像が4枚なので,[4]。
                     //↑ここは書き直し忘れやすいので注意!
    public void init()		// 画像の読み込み
    {
	img[0] = getImage(getDocumentBase(), "1.gif");
	img[1] = getImage(getDocumentBase(), "2.gif");
	img[2] = getImage(getDocumentBase(), "3.gif");
	img[3] = getImage(getDocumentBase(), "4.gif");
    }
    
    public void paint(Graphics g) // 画像表示
    {
	g.drawImage( img[0],0,0, this ); 
	g.drawImage( img[1],50,0, this );  //x軸を変えて画像が
	g.drawImage( img[2],100,0, this ); //重ならないようにする。
	g.drawImage( img[3],150,0, this );
    }
}








選択肢 投票
40  


添付ファイル: file1.gif 2322件 [詳細] filepuzzle1.gif 3112件 [詳細] filepuzzle1.java 770件 [詳細] filepuzzle1.html 862件 [詳細]


topJava教室 ≫ 画像を表示する