// Processed by NMI's Java Code Viewer 4.8.2 © 1997-2000 B. Lemaire // Website: http://njcv.htmlplanet.com E-mail: info@njcv.htmlplanet.com // Copy registered to Evaluation Copy // Source File Name: AboutDialog.java import java.awt.*; import java.io.File; public class AboutDialog extends Window { private Image offImage; private Graphics offGraphics; private int index; private boolean up; private Timer timer; private Toolkit toolkit; private MediaTracker tracker; private Image cup[]; private boolean flag; private Font font; private FontMetrics metrics; public AboutDialog(Frame frame, boolean flag1) { super(frame); up = true; toolkit = getToolkit(); cup = new Image[15]; flag = false; flag = flag1; setLayout(null); resize(insets().left + insets().right + 313, insets().top + insets().bottom + 230); setBackground(Color.lightGray); loadImages(); } public void loadImages() { tracker = new MediaTracker(this); for(int i = 1; i <= 15; i++) { cup[i - 1] = toolkit.getImage("images" + File.separator + "t" + i + ".gif"); tracker.addImage(cup[i - 1], 0); } try { tracker.waitForAll(); return; } catch(InterruptedException _ex) { return; } } public void paint(Graphics g) { update(g); } public void update(Graphics g) { if(!tracker.checkAll()) { g.clearRect(0, 0, size().width, size().height); return; } if(offGraphics == null) { offImage = createImage(size().width, size().height); offGraphics = offImage.getGraphics(); offGraphics.setColor(Color.gray); offGraphics.draw3DRect(0, 0, size().width - 1, size().height - 1, true); font = new Font("TimesRoman", 1, 16); metrics = getFontMetrics(font); offGraphics.setFont(font); offGraphics.setColor(Color.black); String s = "Scrabble in Java"; offGraphics.drawString(s, 220 - metrics.stringWidth(s) / 2, 60); s = "by"; offGraphics.drawString(s, 220 - metrics.stringWidth(s) / 2, 80); s = "Koby Lior"; offGraphics.drawString(s, 220 - metrics.stringWidth(s) / 2, 100); offGraphics.drawString("Fruchtnis Shadhan", 150, 120); font = new Font("TimesRoman", 0, 12); metrics = getFontMetrics(font); offGraphics.setFont(font); s = "Copyright 1997"; offGraphics.drawString(s, 220 - metrics.stringWidth(s) / 2, 165); s = "All Rights Reserved"; offGraphics.drawString(s, 220 - metrics.stringWidth(s) / 2, 180); } offGraphics.clearRect(0, 0, 133, 200); offGraphics.drawImage(cup[index], 2, 0, this); g.drawImage(offImage, 0, 0, this); } public synchronized void show() { Rectangle rectangle = bounds(); addNotify(); move((toolkit.getScreenSize().width - rectangle.width) / 2, (toolkit.getScreenSize().height - rectangle.height) / 2); super.show(); validate(); timer = new Timer(this, 200, true, 1001, 2); timer.start(); } public boolean handleEvent(Event event) { if(event.id == 501 && !flag) { hide(); timer = null; getParent().repaint(); return true; } if(event.target == timer && event.id == 1001) { if(up) { if(index < 14) { index++; } else { up = false; index--; } } else if(index > 0) { index--; } else { up = true; index++; if(flag) { hide(); timer = null; getParent().show(); return true; } } repaint(2, 2, 135, 202); return true; } else { return false; } } }