23Mar

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

  1. import java.applet.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import java.awt.SystemColor.*;
  5. import java.net.*;
  6. import java.io.*;
  7.  
  8. public class SwPlay extends Applet {
  9.  
  10. public static void main (String[] s) {
  11.  
  12. new AppletShell("Star Wars",500,250,false, false, new SwPlay());
  13. }
  14.  
  15. DisplayArea displayArea = new DisplayArea(13, 67);
  16. MouseProcessor mouseProcessor = new MouseProcessor();
  17.  
  18. SwPlayThread threadMain;
  19.  
  20. public void init() {
  21. System.out.println("Inside INIT method");
  22. setLayout(new BorderLayout());
  23. displayArea.setForeground(Color.white);
  24. displayArea.setBackground(Color.black);
  25. this.add( displayArea, BorderLayout.CENTER );
  26. displayArea.show();
  27. show();
  28. }
  29.  
  30. public void start() {
  31. System.out.println( "Inside START method" );
  32. if( ( threadMain == null ) || ( threadMain.isAlive() == false ) ){
  33. System.out.println( "Starting new thread" );
  34. threadMain = new SwPlayThread();
  35. threadMain.bFastForward = false;
  36. System.out.println("Adding mouse listener");
  37. displayArea.addMouseListener( mouseProcessor );
  38. System.out.println("Getting resource stream");
  39. threadMain.inputStream = getClass().getResourceAsStream( "data/sw1.txt" );
  40. if( threadMain.inputStream == null ){
  41. System.out.println( "Getting resource failed" );
  42. }
  43. if( threadMain == null ){
  44. System.out.println( "New threadMain failed" );
  45. }
  46. threadMain.bAtEnd = false;
  47. threadMain.displayArea = displayArea;
  48. threadMain.start();
  49. } else {
  50. System.out.println( "Resuming thread" );
  51. threadMain.newResume();
  52. }
  53. }
  54.  
  55. public void stop() {
  56. System.out.println( "Inside STOP method" );
  57. if( threadMain.bAtEnd == false ) {
  58. System.out.println( "Suspending thread" );
  59. threadMain.newSuspend();
  60. } else {
  61. System.out.println( "Stopping thread" );
  62. threadMain.newStop();
  63. threadMain = null;
  64. }
  65. }
  66.  
  67. public void destroy() {
  68. System.out.println( "Inside DESTROY method" );
  69. displayArea.destroy();
  70. if( threadMain != null ){
  71. System.out.println( "Stopping thread" );
  72. threadMain.stop();
  73. threadMain = null;
  74. }
  75. }
  76.  
  77. //------------------------------------------------------------------------------
  78.  
  79. class MouseProcessor extends MouseAdapter{
  80.  
  81. MouseProcessor(){
  82. System.out.println("Inside MouseProcessor Constructor method");
  83. }
  84.  
  85. public void mousePressed(MouseEvent e){
  86. System.out.println("Inside PRESSED method: FAST FORWARD");
  87. threadMain.bFastForward = true;
  88. threadMain.interrupt();
  89. }
  90.  
  91. public void mouseReleased(MouseEvent e){
  92. System.out.println("Inside RELEASED method: NORMAL SPEED");
  93. threadMain.bFastForward = false;
  94. threadMain.interrupt();
  95. }
  96. }
  97.  
  98. //------------------------------------------------------------------------------
  99.  
  100. public class SwPlayThread extends Thread {
  101. public boolean bAtEnd;
  102. public boolean bFastForward;
  103. public DisplayArea displayArea;
  104. public InputStream inputStream;
  105. public InputStreamReader inputStreamReader;
  106. public LineNumberReader lineNumberReader;
  107. public MouseListener mouseListener;
  108. .......................

点击下载starwars.zip

One Response to “星球大战源码 (JAR) Simon Jansen (C) 1999”

  1. 匿名

    不错哈,呵呵!

    管理员回复: 来源网络!

Leave a Reply