/* RandomLogo application shows procedure to extract image resource from class-loader; also applies for win32 application generated from jexegen.exe. M. Gallant 10/15/2001 */ package com.javascience.msapps ; import java.awt.*; import java.awt.image.*; import java.net.*; import java.awt.event.*; public class RandomLogo extends Frame { private Image image; private Thread runner; int wwidth, wheight ; private final String mes = "jexegen demonstration with image Java resource; by M. Gallant 10/15/2001" ; URL url = null ; public RandomLogo(){ url = getClass().getResource("Thelogo.gif"); image = Toolkit.getDefaultToolkit().getImage(url) ; addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); setSize(750, 200); setTitle(getClass().getName()); wwidth = this.getSize().width; wheight = this.getSize().height ; // System.out.println("Image: " + image + "\nResource: " + url + "\n") ; } public void update(Graphics g) { paint(g) ; } public void paint(Graphics g){ g.drawImage(image, 10, 40, this); g.drawString(mes, 10, 100) ; g.drawString("Resource: " + url, 10, 130) ; g.drawString("Image: " + image , 10, 150) ; } public static void main(String args[]){ RandomLogo f = new RandomLogo(); f.show(); } }