Results 1 to 9 of 9
  1. #1
    dyelax is offline Member
    Join Date
    Oct 2010
    Posts
    41
    Rep Power
    0

    Default Uncaught error fetching image

    Hey guys, I'm trying to make an SSCCE of my Checkers program to put up here for help but every time i try to run it, it comes up with a blank applet window that doesn't respond when I try to close it. Here are the errors I'm getting and the code for my Images is below:
    P.S. I checked all the links and they're valid.

    Java Code:
    Uncaught error fetching image:
    java.lang.SecurityException
    	at java.lang.SecurityManager.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkConnect(Unknown Source)
    	at sun.awt.image.URLImageSource.checkSecurity(Unknown Source)
    	at sun.awt.image.ImageRepresentation.imageComplete(Unknown Source)
    	at sun.awt.image.InputStreamImageSource.errorConsumer(Unknown Source)
    	at sun.awt.image.InputStreamImageSource.setDecoder(Unknown Source)
    	at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
    	at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
    	at sun.awt.image.ImageFetcher.run(Unknown Source)
    Java Code:
            Image checkerboard;
            Image redChecker;
            Image redCheckerKing;
            Image blackChecker;
            Image blackCheckerKing;
            Image pSelect;
            Image select;
            Image sDot;
            URL base;
            MediaTracker mt;
            
            Graphics bufferGraphics;
            Image offscreen;
            
            public CheckersGameSSCCE(){}
            
            public void init(){
            	mt = new MediaTracker(this);
                
            	try {
         	               base = getDocumentBase();
        	         }
                	         catch (Exception e) {} 
                	              
                checkerboard = getImage(base,"http://www.world-wide-net.com/library/graphics/8x8.gif");
                redChecker = getImage(base,"http://www.ozark.k12.mo.us/jrhi/cooks/redcircle.gif");
                blackChecker = getImage(base,"http://s2.webstarts.com/famousmarketstrategies/uploads/Black_circle.jpg");
                pSelect = getImage(base,"http://www.clipartguide.com/_small/0808-0710-2914-4646.jpg");
                select = getImage(base,"http://www.clipartguide.com/_small/0808-0710-2914-4641.jpg");
                sDot = getImage(base,"http://www.visasint.com/images/GreyCircleGif.gif");
                
                mt.addImage(checkerboard,1);
                mt.addImage(redChecker,2);
                mt.addImage(blackChecker,3);
                mt.addImage(pSelect,4);
                mt.addImage(select,5);
                mt.addImage(sDot,6);
                
                try {
                    mt.waitForAll();
                	}
               catch (InterruptedException  e) {}

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    That's not an SSCCE. That being said, the solution: sign the applet:
    What Applets Can and Cannot Do (The Java™ Tutorials > Deployment > Applets)

  3. #3
    dyelax is offline Member
    Join Date
    Oct 2010
    Posts
    41
    Rep Power
    0

    Default

    I know its not an SSCCE but I need to fix this problem before I can put up the SSCCE for my real problem. Are you sure I need to sign it? I had a version of this code working perfectly before without signing it. Also I don't really understand the sites I have been to explaining how to sign applets, so If i do need to do that could you break it down for me? I'm pretty new to this stuff.

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    I know its not an SSCCE but I need to fix this problem before I can put up the SSCCE for my real problem. Are you sure I need to sign it? I had a version of this code working perfectly before without signing it. Also I don't really understand the sites I have been to explaining how to sign applets, so If i do need to do that could you break it down for me? I'm pretty new to this stuff.
    I'm not sure I understand - posting an SSCCE with the problem that is reproducible helps others run the code and reproduce/diagnose the problem. But whatever...

    The error probably was not thrown in one environment because of how applet security works. Deploy in another environment in which something is not allowed and the exception gets thrown.

    I always post this link: OTN Discussion Forums : How to sign an applet (and get it to ...
    It should walk you through it and I couldn't do a better job at explaining it.

  5. #5
    dyelax is offline Member
    Join Date
    Oct 2010
    Posts
    41
    Rep Power
    0

    Default

    Thanks doWhile, I still dont understand where its telling me to go after step 2. I have sdk 6 update 24 but I cant find a path on my computer that looks like the one they used. Here's an SSCCE if you think it will help. I'm trying to run it in Eclipse.

    Java Code:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    public class CheckersGameSSCCE extends Applet implements MouseMotionListener, MouseListener{
    	public BlackChecker b [] = new BlackChecker [12];
    	public RedChecker r [] = new RedChecker [12];
    	public int board[][] = new int [][] 
    	       {{0,1,0,1,0,1,0,1},
    			{1,0,1,0,1,0,1,0},
    			{0,1,0,1,0,1,0,1},
    			{0,0,0,0,0,0,0,0},
    			{0,0,0,0,0,0,0,0},
    			{2,0,2,0,2,0,2,0},
    			{0,2,0,2,0,2,0,2},
    			{2,0,2,0,2,0,2,0}};
    	
    	int xpos;
    	int ypos;
    	public int xposc;
    	public int yposc;
    	boolean rCheckerPSelect [] = new boolean [12];
    	boolean bCheckerPSelect [] = new boolean [12];
    	boolean rCheckerSelect [] = new boolean [12];
    	boolean bCheckerSelect [] = new boolean [12];
            
            Color bgColor = Color.black;
            
            Image checkerboard;
            Image redChecker;
            Image redCheckerKing;
            Image blackChecker;
            Image blackCheckerKing;
            Image pSelect;
            Image select;
            Image sDot;
            URL base;
            MediaTracker mt;
            
            Graphics bufferGraphics;
            Image offscreen;
            
            public CheckersGameSSCCE(){}
            
            public void init(){
            	mt = new MediaTracker(this);
                
            	try {
         	               base = getDocumentBase();
        	         }
                	         catch (Exception e) {} 
                	              
                checkerboard = getImage(base,"http://www.world-wide-net.com/library/graphics/8x8.gif");
                redChecker = getImage(base,"http://www.ozark.k12.mo.us/jrhi/cooks/redcircle.gif");
                blackChecker = getImage(base,"http://s2.webstarts.com/famousmarketstrategies/uploads/Black_circle.jpg");
                pSelect = getImage(base,"http://www.clipartguide.com/_small/0808-0710-2914-4646.jpg");
                select = getImage(base,"http://www.clipartguide.com/_small/0808-0710-2914-4641.jpg");
                sDot = getImage(base,"http://www.visasint.com/images/GreyCircleGif.gif");
                
                mt.addImage(checkerboard,1);
                mt.addImage(redChecker,2);
                mt.addImage(blackChecker,3);
                mt.addImage(pSelect,4);
                mt.addImage(select,5);
                mt.addImage(sDot,6);
                
                try {
                    mt.waitForAll();
                	}
               catch (InterruptedException  e) {} 
    
               addMouseMotionListener(this);
               addMouseListener(this);
               
               setBackground(bgColor);
               resize(600,600);
               
               offscreen = createImage(600,600);
               bufferGraphics = offscreen.getGraphics();
               
               BlackChecker b1 = new BlackChecker(1,0,75,0);
               BlackChecker b2 = new BlackChecker(3,0,225,0);
               BlackChecker b3 = new BlackChecker(5,0,375,0);
               BlackChecker b4 = new BlackChecker(7,0,525,0);
               BlackChecker b5 = new BlackChecker(0,1,0,75);
               BlackChecker b6 = new BlackChecker(2,1,150,75);
               BlackChecker b7 = new BlackChecker(4,1,300,75);
               BlackChecker b8 = new BlackChecker(6,1,450,75);
               BlackChecker b9 = new BlackChecker(1,2,75,150);
               BlackChecker b10 = new BlackChecker(3,2,225,150);
               BlackChecker b11 = new BlackChecker(5,2,375,150);
               BlackChecker b12 = new BlackChecker(7,2,525,150);
               b[0] = b1;
               b[1] = b2;
               b[2] = b3;
               b[3] = b4;
               b[4] = b5;
               b[5] = b6;
               b[6] = b7;
               b[7] = b8;
               b[8] = b9;
               b[9] = b10;
               b[10] = b11;
               b[11] = b12;
               
               
               RedChecker r1 = new RedChecker(0,5,0,375);
               RedChecker r2 = new RedChecker(2,5,150,375);
               RedChecker r3 = new RedChecker(4,5,300,375);
               RedChecker r4 = new RedChecker(6,5,450,375);
               RedChecker r5 = new RedChecker(1,6,75,450);
               RedChecker r6 = new RedChecker(3,6,225,450);
               RedChecker r7 = new RedChecker(5,6,375,450);
               RedChecker r8 = new RedChecker(7,6,525,450);
               RedChecker r9 = new RedChecker(0,7,0,525);
               RedChecker r10 = new RedChecker(2,7,150,525);
               RedChecker r11 = new RedChecker(4,7,300,525);
               RedChecker r12 = new RedChecker(6,7,450,525);
               r[0] = r1;
               r[1] = r2;
               r[2] = r3;
               r[3] = r4;
               r[4] = r5;
               r[5] = r6;
               r[6] = r7;
               r[7] = r8;
               r[8] = r9;
               r[9] = r10;
               r[10] = r11;
               r[11] = r12;
               
    
               
           }
           
           public void stop(){
           }
           
           public void paint(Graphics g){
           
           bufferGraphics.clearRect(0,0,600,600);
           
           bufferGraphics.drawImage(checkerboard, 0, 0, 600, 600, this);
           
           for(int i = 0; i < 12; i++){
               bufferGraphics.drawImage(blackChecker, b[i].blackCheckerBoardX, b[i].blackCheckerBoardY, 75, 75, this);
               bufferGraphics.drawImage(redChecker, r[i].redCheckerBoardX, r[i].redCheckerBoardY, 75, 75, this);
               if(rCheckerPSelect[i]){
               	bufferGraphics.drawImage(pSelect, r[i].redCheckerBoardX, r[i].redCheckerBoardY, 75, 75, this);
               }
               if(bCheckerPSelect[i]){
               	bufferGraphics.drawImage(pSelect, b[i].blackCheckerBoardX, b[i].blackCheckerBoardY, 75, 75, this);
               }
               if(rCheckerSelect[i]){
               	bufferGraphics.drawImage(select, r[i].redCheckerBoardX, r[i].redCheckerBoardY, 75, 75, this);
               	if(board[r[i].redCheckerX-1][r[i].redCheckerY-1] == 0){
               		bufferGraphics.drawImage(sDot, r[i].redCheckerBoardX-75, r[i].redCheckerBoardY-75, 75, 75, this);
               	}
               	if(board[r[i].redCheckerX-1][r[i].redCheckerY-1] == 1 && board[r[i].redCheckerX-2][r[i].redCheckerY-2] == 0){
               		bufferGraphics.drawImage(sDot, r[i].redCheckerBoardX-150, r[i].redCheckerBoardY-150, 75, 75, this);
               	}
               	if(board[r[i].redCheckerX+1][r[i].redCheckerY-1] == 0){
               		bufferGraphics.drawImage(sDot, r[i].redCheckerBoardX+75, r[i].redCheckerBoardY-75, 75, 75, this);
               	}
               	if(board[r[i].redCheckerX+1][r[i].redCheckerY-1] == 1 && board[r[i].redCheckerX+2][r[i].redCheckerY-2] == 0){
               		bufferGraphics.drawImage(sDot, r[i].redCheckerBoardX+150, r[i].redCheckerBoardY-150, 75, 75, this);
               	}
               	RedChecker.Move(i);
               }
               if(bCheckerSelect[i]){
               	bufferGraphics.drawImage(select, b[i].blackCheckerBoardX, b[i].blackCheckerBoardY, 75, 75, this);
               	if(board[b[i].blackCheckerX-1][b[i].blackCheckerY+1] == 0){
               		bufferGraphics.drawImage(sDot, b[i].blackCheckerBoardX-75, b[i].blackCheckerBoardY+75, 75, 75, this);
               	}
               	if(board[b[i].blackCheckerX-1][b[i].blackCheckerY+1] == 2 && board[b[i].blackCheckerX-2][b[i].blackCheckerY+2] == 0){
               		bufferGraphics.drawImage(sDot, b[i].blackCheckerBoardX-150, b[i].blackCheckerBoardY+150, 75, 75, this);
               	}
               	if(board[b[i].blackCheckerX+1][b[i].blackCheckerY+1] == 0){
               		bufferGraphics.drawImage(sDot, b[i].blackCheckerBoardX+75, b[i].blackCheckerBoardY+75, 75, 75, this);
               	}
               	if(board[b[i].blackCheckerX+1][b[i].blackCheckerY+1] == 2 && board[b[i].blackCheckerX+2][b[i].blackCheckerY+2] == 0){
               		bufferGraphics.drawImage(sDot, b[i].blackCheckerBoardX+150, b[i].blackCheckerBoardY+150, 75, 75, this);
               	}
               	BlackChecker.Move(i);
               }
           }        
           /*bufferGraphics.setColor(Color.red);
           bufferGraphics.drawString("("+xpos+","+ypos+")",xpos,ypos);*/
           g.drawImage(offscreen, 0, 0, this);
       }
           
           public void update(Graphics g){
           	paint(g);
           }
       
       public void mouseMoved(MouseEvent me){
           xpos = me.getX();
           ypos = me.getY();
           repaint();
           for(int i = 0; i < 12; i++){
               if((xpos >= r[i].redCheckerBoardX && xpos <= (r[i].redCheckerBoardX+75))&&(ypos >= r[i].redCheckerBoardY && ypos <= (r[i].redCheckerBoardY+75))){
                   rCheckerPSelect[i] = true;
                   repaint();
               }
               else{
               	rCheckerPSelect[i] = false;
               }
               if((xpos >= b[i].blackCheckerBoardX && xpos <= (b[i].blackCheckerBoardX+75))&&(ypos >= b[i].blackCheckerBoardY && ypos <= (b[i].blackCheckerBoardY+75))){
                   bCheckerPSelect[i] = true;
                   repaint();
               }
               else{
               	bCheckerPSelect[i] = false;
               }
           }
       }
           public void mouseDragged(MouseEvent me){}
           public void mouseClicked(MouseEvent me){
               xposc = me.getX();
               yposc = me.getY();
               repaint();
               for(int i = 0; i < 12; i++){
                   if((xposc >= r[i].redCheckerBoardX && xposc <= (r[i].redCheckerBoardX+75))&&(yposc >= r[i].redCheckerBoardY && yposc <= (r[i].redCheckerBoardY+75))){
                       rCheckerSelect[i] = true;
                       repaint();
                   }
                   else{
                   	rCheckerSelect[i] = false;
                   }
                   if((xposc >= b[i].blackCheckerBoardX && xposc <= (b[i].blackCheckerBoardX+75))&&(yposc >= b[i].blackCheckerBoardY && yposc <= (b[i].blackCheckerBoardY+75))){
                       bCheckerSelect[i] = true;
                       repaint();
                   }
                   else{
                   	bCheckerSelect[i] = false;
                   }
               }
           }
           public void mousePressed(MouseEvent me){}
           public void mouseReleased(MouseEvent me){}
           public void mouseEntered(MouseEvent me){}
           public void mouseExited(MouseEvent me){}
       }
    Java Code:
    public class BlackChecker{
    
    	public int blackCheckerX;
    	public int blackCheckerY;
    	public int blackCheckerBoardX;
    	public int blackCheckerBoardY;
    	
    	public BlackChecker(int x, int y, int bx, int by){
    		blackCheckerX = x;
    		blackCheckerY = y;
    		blackCheckerBoardX = bx;
    		blackCheckerBoardY = by;
    	}
    	
    	static CheckersGameSSCCE c = new CheckersGameSSCCE();
    	
    	public static void Move(int i)
    	{
    		int x = c.b[i].blackCheckerBoardX;
    		int y = c.b[i].blackCheckerBoardY;
    		int xi = c.b[i].blackCheckerX;
    		int yi = c.b[i].blackCheckerY;
    		int cx = c.xposc;
    		int cy = c.yposc;
    
    		if (cy >= y - 75 && cy <= y)
    		{
    			if      ((cx >= x + 75 && cx <= x + 150) && c.board[xi + 1][yi - 1] == 0) {
    				c.b[i].blackCheckerBoardX += 75;
    				c.b[i].blackCheckerBoardY -= 75;
    				c.b[i].blackCheckerX++;
    				c.b[i].blackCheckerY--;
    				c.repaint();
    			}
    			else if ((cx >= x - 75 && cx <= x)       && c.board[xi + 1][yi - 1] == 0) {
    				c.b[i].blackCheckerBoardX -= 75;
    				c.b[i].blackCheckerBoardY -= 75;
    				c.b[i].blackCheckerX--;
    				c.b[i].blackCheckerY--;
    				c.repaint();
    			}
    			else if ((cx >= x + 75 && cx <= x + 150) && c.board[xi + 1][yi - 1] == 2 && c.board[xi + 2][yi - 2] == 0) {
    				c.b[i].blackCheckerBoardX += 150;
    				c.b[i].blackCheckerBoardY -= 150;
    				c.b[i].blackCheckerX += 2;
    				c.b[i].blackCheckerY -= 2;
    				c.repaint();
    			}
    			else if ((cx >= x - 75 && cx <= x)       && c.board[xi - 1][yi - 1] == 2 && c.board[xi - 2][yi - 2] == 0) {
    				c.b[i].blackCheckerBoardX -= 150;
    				c.b[i].blackCheckerBoardY -= 150;
    				c.b[i].blackCheckerX -= 2;
    				c.b[i].blackCheckerY -= 2;
    				c.repaint();
    			}
    		}
    	}
    }
    Java Code:
    public class RedChecker {
    	
    	public int redCheckerX;
    	public int redCheckerY;
    	public int redCheckerBoardX;
    	public int redCheckerBoardY;
    	
    	public RedChecker(int x, int y, int bx, int by){
    		redCheckerX = x;
    		redCheckerY = y;
    		redCheckerBoardX = bx;
    		redCheckerBoardY = by;
    	}
    	
    static CheckersGameSSCCE c = new CheckersGameSSCCE();
    	
    	public static void Move(int i)
    	{
    		int x = c.r[i].redCheckerBoardX;
    		int y = c.r[i].redCheckerBoardY;
    		int xi = c.r[i].redCheckerX;
    		int yi = c.r[i].redCheckerY;
    		int cx = c.xposc;
    		int cy = c.yposc;
    
    		if (cy >= y - 75 && cy <= y)
    		{
    			if      ((cx >= x + 75 && cx <= x + 150) && c.board[xi + 1][yi - 1] == 0) {
    				c.r[i].redCheckerBoardX += 75;
    				c.r[i].redCheckerBoardY -= 75;
    				c.r[i].redCheckerX++;
    				c.r[i].redCheckerY--;
    				c.repaint();
    			}
    			else if ((cx >= x - 75 && cx <= x)       && c.board[xi + 1][yi - 1] == 0) {
    				c.r[i].redCheckerBoardX -= 75;
    				c.r[i].redCheckerBoardY -= 75;
    				c.r[i].redCheckerX--;
    				c.r[i].redCheckerY--;
    				c.repaint();
    			}
    			else if ((cx >= x + 75 && cx <= x + 150) && c.board[xi + 1][yi - 1] == 2 && c.board[xi + 2][yi - 2] == 0) {
    				c.r[i].redCheckerBoardX += 150;
    				c.r[i].redCheckerBoardY -= 150;
    				c.r[i].redCheckerX += 2;
    				c.r[i].redCheckerY -= 2;
    				c.repaint();
    			}
    			else if ((cx >= x - 75 && cx <= x)       && c.board[xi - 1][yi - 1] == 2 && c.board[xi - 2][yi - 2] == 0) {
    				c.r[i].redCheckerBoardX -= 150;
    				c.r[i].redCheckerBoardY -= 150;
    				c.r[i].redCheckerX -= 2;
    				c.r[i].redCheckerY -= 2;
    				c.repaint();
    			}
    		}
    	}
    }
    Last edited by dyelax; 03-20-2011 at 03:55 PM.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    That's way too much code and many here won't read it. You may wish to re-read the SSCCE description in its link (see below). If you create and post a decent SSCCE, your chances of getting a decent quick answer go way up.

  7. #7
    dyelax is offline Member
    Join Date
    Oct 2010
    Posts
    41
    Rep Power
    0

    Default

    i dont know which part I should cut out to make it shorter as I dont know what the problem I am getting means. Thats what I need to know from this thread

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Then don't try and chop and change your code. Create a completely different program that reproduces your problem. Chances are that in doing this you will realise what the problem is.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Junky View Post
    Then don't try and chop and change your code. Create a completely different program that reproduces your problem. Chances are that in doing this you will realise what the problem is.
    AMEN and well spoken!

Similar Threads

  1. Uncaught error fetching image
    By Manfizy in forum New To Java
    Replies: 9
    Last Post: 12-03-2011, 04:16 PM
  2. catching uncaught exceptions using Spring / WebApp
    By taille50 in forum Web Frameworks
    Replies: 1
    Last Post: 10-18-2009, 01:14 AM
  3. Do uncaught errors appear in the PrintStream?
    By arnab321 in forum New To Java
    Replies: 1
    Last Post: 02-26-2009, 08:56 AM
  4. Replies: 2
    Last Post: 07-13-2008, 05:46 PM
  5. Fetching rows from DB
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-06-2008, 09:23 AM

Posting Permissions

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