import java.awt.*; import java.util.*; import java.applet.*; import java.awt.event.*; // // 'Canvas' to draw everything on (Applet) // public class begin extends Applet implements Runnable{ Image buffer; Graphics canvas; int k=0; int state=0; Game game; ProgressionBar thread; boolean loaded=false; public int MAXHEIGHT=(int)(Toolkit.getDefaultToolkit().getScreenSize().height); public int MAXWIDTH=(int)(Toolkit.getDefaultToolkit().getScreenSize().width); public boolean showprogress=false; int drawtime=-1; public void init(){ setLayout(null); setBackground(new Color(0,60,0)); buffer=createImage(MAXWIDTH, MAXHEIGHT); canvas=buffer.getGraphics(); } // // Default called by the applet initialization // public void start(){ try{ thread=new ProgressionBar(this); // thread.setPriority(Thread.MIN_PRIORITY); thread.setPriority(Thread.MAX_PRIORITY); thread.start(); }catch(Exception exception){ System.out.println("(begin-start-ProgressionBar): "+exception.toString()); } // seperate thread to start loading application try{ Thread thr=new Thread(this); thr.start(); }catch(Exception exception){ System.out.println("(begin-start-thr): "+exception.toString()); } } // // When applet / browser (window) gets closed // public void stop(){ if(thread!=null) thread.stop(); if(game!=null){ game.stop(); } } // // Thread running // public void run(){ int ij=0; System.out.println("With ij-loop we wait a bit for the progressionbar to show"); // while(!loaded){ while(true){ // progression bar repaint(); if(ij++==200){ // Initialize the Game try{ Class c=Class.forName("aGame"); if(c != null){ // game=new aGame(this); game=(Game)c.newInstance(); game.init(this); }else{ System.out.println("Class is null!"); } }catch(Exception exception){ System.out.println("Error loading aGame!:"+exception); } } // animation sleep try{ Thread.sleep(10); }catch(Exception e){ } } } // // Graphics routines // public void paint(Graphics g){ update(g); } public void update(Graphics g){ // Progressionbar thread is going to paint on this //System.out.println("Updating in begin"); g.drawImage(buffer, 0, 0, this); } public boolean imageUpdate( Image img, int flags, int x, int y, int w, int h ) { repaint(); return true; } }