Har rettet lidt i dit url path halløj, for at få det til at passe med min maskine.
Men applet'en loader og viser det billede jeg beder den om.
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;
import java.io.InputStream;
import java.net.URL;
public class AWTApplet extends Applet implements Runnable
{
Thread RunningThread;
Image Buffer;
Graphics GraphicsBuffer;
String ImageHost = "
http://192.168.1.39"; String SSIHost = "
http://192.168.1.39"; String SSIDirectory = "/SSI/";
String ImageDirectory = "/img/";
Image Background;
public void init()
{
setSize( 300,200 );
Buffer = createImage(size().width,size().height);
GraphicsBuffer = Buffer.getGraphics();
initImages();
drawImages();
initComponents();
}
private void initComponents()
{
// setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
}
public void start()
{
if (RunningThread == null)
{
RunningThread = new Thread(this);
RunningThread.start();
}
}
public void stop()
{
if (RunningThread != null)
{
RunningThread.stop();
RunningThread = null;
}
}
public void run()
{
while(true)
{
drawImages();
repaint();
System.out.println("repaint()");
Sleep( 5000 );
}
}
private void Sleep( int time )
{
try
{
RunningThread.sleep( time );
}
catch( InterruptedException e )
{
e = null;
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(Buffer,0,0, this);
}
private String ReadStringValueFromURL( String url )
{
String Value = "";
try
{
URL URL_Til_Aflæsning = new URL( "
http://www.disky.dk/index.html");
InputStream IO = URL_Til_Aflæsning.openStream();
byte[] byteArray = new byte[IO.available()];
IO.read( byteArray );
for( int index = 0; index < byteArray.length; index++ )
{
Value += (char) byteArray[index];
}
}
catch( java.security.AccessControlException E )
{
Value += "{Access Denied}";
E = null;
}
catch( java.net.MalformedURLException E )
{
Value += "{Bad URL}";
E = null;
}
catch( java.io.IOException E )
{
Value += "{IO Exception}";
E = null;
}
catch( Exception E )
{
Value += "{Error}";
E = null;
}
return Value;
}
private Image ReadImageFromURL( String url )
{
try
{
URL adresse = new java.net.URL( /*ImageHost + ImageDirectory + */url);
Image icon = getImage( adresse );
if( icon == null )
{
System.out.println( "No image. URL: [" + ImageHost + ImageDirectory + url + "]" );
}
return icon;
}
catch( Exception E )
{
E.printStackTrace();
E = null;
}
return null;
}
private void drawImage( Image ImageToManipulate, int x_coords, int y_coords, int width, int height )
{
GraphicsBuffer.drawImage(ImageToManipulate, x_coords, y_coords,width, height, null);
}
private void drawImages()
{
if(Background!=null)
{
drawImage( Background, 0, 0, 1013, 609 );
}
}
private void initImages()
{
Background = ReadImageFromURL( "
file:///e:\\Udvikling\\fishbanner.jpg" );
}
}