close

package javaapplication1;

import java.awt.*;
import java.applet.Applet;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class Main extends Applet {
    JFrame f = new JFrame("Load Image Sample");
    Image frame1;
    Image frame2;
    Image frame3;
    public Main() throws IOException {
        frame1 = new ImageIcon("F:/專題/拍手.gif").getImage();
        frame2 = new ImageIcon("F:/專題/1775465290.gif").getImage();
        frame3 = new ImageIcon("F:/專題/1775465291.gif").getImage();
        repaint();
    }
    public void paint(Graphics g) {
        g.drawImage(frame1, 0, 0, this);
        g.drawImage(frame2, frame1.getWidth(null), frame1.getHeight(null), this);
        g.drawImage(frame3, frame1.getWidth(null)*2, frame1.getHeight(null)*2, this);
    }
    public Dimension getPreferredSize(){
        if (frame1 == null)
            return new Dimension(100,100);
        else
            return new Dimension(frame1.getWidth(null)*3, frame1.getHeight(null)*3);
    }
    public static void main(String[] args) throws IOException {
        final Main main = new Main();
        main.f.addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
        main.f.add(main);
        main.f.pack();
        main.f.setVisible(true);
    }
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 lupohsunrock 的頭像
    lupohsunrock

    lupohsunrock的部落格

    lupohsunrock 發表在 痞客邦 留言(0) 人氣()