[Mndiff-dev] [mndiff]: r13 - trunk/TicTacToe/TicTacToe.java
michael
subversion at mplayerhq.hu
Fri May 11 02:42:56 CEST 2007
Author: michael
Date: Fri May 11 02:42:56 2007
New Revision: 13
Log:
make it find the .jpgs in a .jar
remove try/catch as javac refuses to compile it otherwise
Modified:
trunk/TicTacToe/TicTacToe.java
Modified: trunk/TicTacToe/TicTacToe.java
==============================================================================
--- trunk/TicTacToe/TicTacToe.java (original)
+++ trunk/TicTacToe/TicTacToe.java Fri May 11 02:42:56 2007
@@ -45,20 +45,13 @@ public class TicTacToe extends JApplet i
public void init()
{
- try
- {
- icon[0]= new ImageIcon( new URL( getCodeBase(), "empty.jpg" ) );
- icon[1]= new ImageIcon( new URL( getCodeBase(), "x.jpg" ) );
- icon[2]= new ImageIcon( new URL( getCodeBase(), "o.jpg" ) );
- icon[3]= new ImageIcon( new URL( getCodeBase(), "emptyL.jpg" ) );
- icon[4]= new ImageIcon( new URL( getCodeBase(), "xL.jpg" ) );
- icon[5]= new ImageIcon( new URL( getCodeBase(), "oL.jpg" ) );
- }
- catch( MalformedURLException e)
- {
- System.err.println("Cant load Image " + e.getMessage());
- System.exit(1);
- }
+ ClassLoader c= getClass().getClassLoader();
+ icon[0]= new ImageIcon( c.getResource("empty.jpg" ) );
+ icon[1]= new ImageIcon( c.getResource("x.jpg" ) );
+ icon[2]= new ImageIcon( c.getResource("o.jpg" ) );
+ icon[3]= new ImageIcon( c.getResource("emptyL.jpg") );
+ icon[4]= new ImageIcon( c.getResource("xL.jpg" ) );
+ icon[5]= new ImageIcon( c.getResource("oL.jpg" ) );
Container cp= getContentPane();
More information about the Mndiff-dev
mailing list