星球大战源码 (JAR) Simon Jansen (C) 1999

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.SystemColor.*;
import java.net.*;
import java.io.*;

public class SwPlay extends Applet {

public static void main (String[] s) {

new AppletShell("Star Wars",500,250,false, false, new SwPlay());
}

DisplayArea displayArea = new DisplayArea(13, 67);
MouseProcessor mouseProcessor = new MouseProcessor();

SwPlayThread threadMain;

public void init() {
System.out.println("Inside INIT method");
setLayout(new BorderLayout());
displayArea.setForeground(Color.white);
displayArea.setBackground(Color.black);
this.add( displayArea, BorderLayout.CENTER );
displayArea.show();
show();
}

public void start() {
System.out.println( "Inside START method" );
if( ( threadMain == null ) || ( threadMain.isAlive() == false ) ){
System.out.println( "Starting new thread" );
threadMain = new SwPlayThread();
threadMain.bFastForward = false;
System.out.println("Adding mouse listener");
displayArea.addMouseListener( mouseProcessor );
System.out.println("Getting resource stream");
threadMain.inputStream = getClass().getResourceAsStream( "data/sw1.txt" );
if( threadMain.inputStream == null ){
System.out.println( "Getting resource failed" );
}
if( threadMain == null ){
System.out.println( "New threadMain failed" );
}
threadMain.bAtEnd = false;
threadMain.displayArea = displayArea;
threadMain.start();
} else {
System.out.println( "Resuming thread" );
threadMain.newResume();
}
}

public void stop() {
System.out.println( "Inside STOP method" );
if( threadMain.bAtEnd == false ) {
System.out.println( "Suspending thread" );
threadMain.newSuspend();
} else {
System.out.println( "Stopping thread" );
threadMain.newStop();
threadMain = null;
}
}

public void destroy() {
System.out.println( "Inside DESTROY method" );
displayArea.destroy();
if( threadMain != null ){
System.out.println( "Stopping thread" );
threadMain.stop();
threadMain = null;
}
}

//------------------------------------------------------------------------------

class MouseProcessor extends MouseAdapter{

MouseProcessor(){
System.out.println("Inside MouseProcessor Constructor method");
}

public void mousePressed(MouseEvent e){
System.out.println("Inside PRESSED method: FAST FORWARD");
threadMain.bFastForward = true;
threadMain.interrupt();
}

public void mouseReleased(MouseEvent e){
System.out.println("Inside RELEASED method: NORMAL SPEED");
threadMain.bFastForward = false;
threadMain.interrupt();
}
}

//------------------------------------------------------------------------------

public class SwPlayThread extends Thread {
public boolean bAtEnd;
public boolean bFastForward;
public DisplayArea displayArea;
public InputStream inputStream;
public InputStreamReader inputStreamReader;
public LineNumberReader lineNumberReader;
public MouseListener mouseListener;
.......................

点击下载starwars.zip

随机日志

发表评论

1 Comments.

  1. 不错哈,呵呵!

    管理员回复: 来源网络!

Leave a Reply



[ Ctrl + Enter ]

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word