import java.awt.*; import java.awt.Font.*; import java.awt.event.*; import java.applet.*; import java.net.*; public class ZeroWing extends Applet { public void paint(Graphics g) { Dimension d; double locX, locY; int x, y, msgNum; int strX, strY; String msg[] = {"All your base are belong to us.", "How are you gentlemen!!", "Take off every 'ZIG'!!", "Move 'ZIG'", "For great justice.", "What you say?", "You have no chance to survive make your time", "Ha ha ha ....", "Captain!!", "It's you!!", "How are you gentlemen!!", "All your base are belong to us", "You are on the way to destruction", "What happen?", "Someone set up us the bomb", "We get signal", "What!", "Main screen turn on." }; String fonts[] = { "Monospaced", "Serif", "SansSerif" }; int fontSizes[] = { 8, 12, 14, 18, 24, 36, 48, }; for(int i = 0; i < (int) (Math.random() * 20) + 1; ++i) { while(true) { Font f = new Font(fonts[(int)(Math.random()*fonts.length)], Font.BOLD, fontSizes[(int)(Math.random()*fontSizes.length)] ); Color c = new Color((float)Math.random(), (float)Math.random(), (float)Math.random()); g.setColor(c); d = getSize(); x = d.width; y = d.height; g.setFont(f); FontMetrics fm = g.getFontMetrics(); msgNum = (int)(Math.random() * msg.length); strX = fm.stringWidth(msg[msgNum]); strY = fm.getHeight(); if(strX < x && strY < y) { break; } } URL src = null; try { src = new URL("http://lightconsulting.com/~thalakan/images/"); } catch (java.net.MalformedURLException ex) { System.out.println("Bad URL"); return; } Image img = getImage(src, "zw1.png"); g.drawImage(img, 100, 100, this); locX = Math.random(); locX *= (x-strX); locY = Math.random(); locY *= (y-strY); locY += strY; // showStatus("(" + locX + "," + locY + ") | (" + // strX + "," + strY + ")"); g.drawString(msg[msgNum], (int)locX, (int)locY); // g.drawRect((int)locX, (int)(locY-strY), strX, strY); try { java.lang.Thread.sleep(500); } catch (java.lang.InterruptedException ex) { System.out.println(ex.toString()); } repaint(); } } public void init() { } public void start() { showStatus("Starting..."); } public void stop() { showStatus("Stopping..."); } public void destroy() { showStatus("Destroying..."); } }