JDK 1.6.0 Applet Background Issue

Hello All,

I have a simple Java Applet which was working fine in JDK 1.4.x. Here is the code for it:

import java.awt.*;

import java.util.*;

publicclass NewWatchextends javax.swing.JApplet{

private Color white =new Color(0, 0, 0);

private String lastTime ="";

Color back;

publicvoid init(){

String in = getParameter("background");

back = Color.red;

if (in !=null){

try{

back = Color.decode(in);

}catch (NumberFormatException e){

showStatus("Bad parameter " + in);

}

}

setBackground(back);

}

publicvoid paint(Graphics screen){

Graphics2D screen2D = (Graphics2D)screen;

Font type =new Font("Monospaced", Font.BOLD, 12);

screen2D.setFont(type);

GregorianCalendar day =new GregorianCalendar();

String time = day.getTime().toString();

screen2D.setColor(back);

screen2D.drawString(lastTime, 5, 25);

screen2D.setColor(white);

screen2D.drawString(time, 5, 25);

try{

Thread.sleep(1000);

}catch (InterruptedException e){

// do nothing

}

lastTime = time;

repaint();

}

}

And here is the HTML page for it:

<applet code="NewWatch.class" height="40" width="205">

<param name="background" value="#FF000000">

This program requires a Java-enabled browser.

</applet>

You can see a working version of this applet here:

http://www.digioz.com/java.php

The problem is that since upgrading to JDK 1.6.0 this morning, I no longer see the background chosen through the parameter in the HTML code. Has anyone had a similar problem and/or know the solution to this issue?

Thanks,

Pete

[3120 byte] By [DigiOz_Multimediaa] at [2007-11-26 21:19:25]
# 1

I found a solution to my problem, which still does NOT explain why the JApplet class in SDK 1.6.0 is not working the way it should be. The solution is as follows:

Instead of:

public class NewWatch extends javax.swing.JApplet {

If I use:

import java.applet.*;

public class NewWatch extends Applet {

So this is a problem with the "javax.swing.JApplet" class in the SDK 1.6.0. I would be interested to find out if there are any plans on fixing this issue in future releases of SDK. Anyone?

Thanks,

Pete

Message was edited by:

DigiOz_Multimedia

DigiOz_Multimediaa at 2007-7-10 2:58:19 > top of Java-index,Desktop,Core GUI APIs...