Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31
  1. #21
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    When you move all your image files into a jar, you need to treat them as resources instead of files.

  2. #22
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    ok this is the stack trace:
    Java Code:
    java.lang.reflect.InvocationTargetException
    	at java.awt.EventQueue.invokeAndWait(Unknown Source)
    	at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
    	at jChess.applet.appletMain.init(appletMain.java:48)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission maroon read)
    	at java.security.AccessControlContext.checkPermission(Unknown Source)
    	at java.security.AccessController.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    	at java.lang.System.getProperty(Unknown Source)
    	at java.lang.Integer.getInteger(Unknown Source)
    	at java.lang.Integer.getInteger(Unknown Source)
    	at java.awt.Color.getColor(Unknown Source)
    	at java.awt.Color.getColor(Unknown Source)
    	at jChess.game.boardCell.<init>(boardCell.java:23)
    	at jChess.game.Board.initBoard(Board.java:79)
    	at jChess.game.Board.<init>(Board.java:59)
    	at jChess.applet.appletMain.createGUI(appletMain.java:78)
    	at jChess.applet.appletMain.access$0(appletMain.java:62)
    	at jChess.applet.appletMain$1.run(appletMain.java:50)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    and this causes the problem ....
    Java Code:
    public boardCell(int x,int y){
    		
    		this.x=x;
    		this.y=y;
    		
    		if ((x+y)%2==0)
    				this.setBackground(Color.getColor("maroon"));
    			else
    				this.setBackground(Color.gray);
    	
    
    	}

    THIS IS THE PROBLEM
    this.setBackground(Color.getColor("maroon"));
    I read it should be like this:

    Java Code:
    Color color;
    try {
        Field field = Class.forName("java.awt.Color").getField("yellow");
        color = (Color)field.get(null);
    } catch (Exception e) {
        color = null; // Not defined
    }

  3. #23
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    Sorry, I have no idea what you are doing to get a Color object. Seems like you can very easily get any color you want with the Color class's constructor.

  4. #24
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    hmm can you show me how to get a file as a resoursce and will it work in the appletViewer too ? i have a method but i dont know how to give it the proper path and where to put the files to make it work. ( the color issue is fixed i just doo
    Java Code:
    Color col= new Color (x,y,z)
    ;)

  5. #25
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    how to get a file as a resoursce
    There are many code samples on this forum. Do a Search for getResource or getResourceAsStream.

  6. #26
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Got it working :D in a Folder - MainPage.html + jChess.jar files :D.
    But when i send it to the online server (apache) i get :

    Java Code:
    Creating GUI
    Seting DIM
    After setting DIM
    After PANE
    After BOARD
    After ADD PANE
    java.lang.ClassFormatError: Incompatible magic value 171731060 in class file applet/appletMain
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClassCond(Unknown Source)
    	at java.lang.ClassLoader.defineClass(Unknown Source)
    	at java.security.SecureClassLoader.defineClass(Unknown Source)
    	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassFormatError: Incompatible magic value 171731060 in class file applet/appletMain
    Any Idea ?

  7. #27
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    Incompatible magic value 171731060 in class file applet/appletMain
    That looks like a corrupted class file. Open that class file (appletMain.class) in a hex editor. The start of the first line should be something like this:
    CAFE BABE 0000 0032 006D 0A001F003D07

  8. #28
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Got it running - had to send the file with a good client not the server web api.
    I have a problem with addding a jar for reading mysql :/. How to add it to the project and export it ??

  9. #29
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    Sounds like an IDE configuration problem. I don't know anything about your IDE.

  10. #30
    oki
    oki is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default

    Eclipse Classic IDE :) . Help me out ... this one is annoying !

  11. #31
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    Try asking on a forum for your IDE. This forum has a section for IDEs.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. applet working in applet viewer, not browser
    By plasticfood in forum Java Applets
    Replies: 4
    Last Post: 06-24-2011, 06:47 PM
  2. Java Applet to Applet communication
    By jsman in forum Java Applets
    Replies: 3
    Last Post: 04-05-2011, 02:23 PM
  3. applet class inside java.applet.* or java.awt.*
    By Manish87 in forum Java Applets
    Replies: 1
    Last Post: 09-27-2010, 02:15 PM
  4. Calling another applet on click of button in one applet
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 1
    Last Post: 02-19-2009, 12:54 PM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •