Hello!
i have no earlier experience with Java Application Sandboxes, this is my first…
i have an following code, it compiles ok and it runs ok from my netbeans ide…
my problem comes when i try to run my executable.jar file from my windows xp by doubleclicking it…
the following code when compiled to jar only returns frame with gray background, no image,
i have tryed to explore google but i have not found an answer…
so, could someone please help a poor coder with why gif wont get displayed when jar is runned localy by doubleclick or from homepage with jnlp ??
i really want to run my application on a sandbox, i dont have similiar problems with signed jars ?
package components;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class myDemo extends Canvas
{
public myDemo()
{
JFrame frame = new JFrame("DamnGood-kickoff!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension dim = new Dimension();
dim.width = 640;
dim.height = 480;
this.setSize(dim);
frame.getContentPane().add(this);
frame.setLocation (200,200);
BufferedImage bimg = loadBImage ("/kuva_002.gif");
frame.pack();
frame.setVisible(true);
while ( true == true )
{
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
this.getGraphics().drawImage(bimg, 0, 0, this);
}
}
//---------------------------------------------------------------------------------------
// BufferedImage loader..
public BufferedImage loadBImage ( String resr ) {
try {
BufferedImage bimg;
bimg = ImageIO.read(new BufferedInputStream(getClass().getResourceAsStream(resr)));
return bimg;
} catch (Exception e) {
System.out.println("Error loading image: " + resr + " " );
System.exit(0);
return null;
}
}
//---------------------------------------------------------------------------------------
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
public static void main(String[] args)
{
myDemo demo = new myDemo ();
}
}
;D