import java.awt.*; class canvas_im extends Canvas { Image im; canvas_im(Image image,fenetre_im f) { im = image; setBackground(Color.white); } public void paint(Graphics g) { int w,h; if (!prepareImage(im,this)) return; g.drawImage(im,0,0,this); } } class fenetre_im extends Frame { fenetre_im(Image im,String titre) { setTitle(titre); resize(150,150); add("Center",new canvas_im(im,this)); } public boolean handleEvent(Event e) { if (e.id == Event.WINDOW_DESTROY) { dispose(); return (true); } return (super.handleEvent(e)); } } public class voir extends java.applet.Applet { Image im; String titre; public void init() { titre = getParameter("image"); im = getImage(getCodeBase(),titre); add ("Center",new Button("Voir l'image")); } public boolean action(Event e,Object arg) { fenetre_im fi = new fenetre_im(im,titre); fi.show(); return (true); } }
Retour