...

View Full Version : JApplet background color



DELOCH
12-24-2007, 08:47 PM
I have a problem with setting a background to JApplet

my code:

import java.awt.geom.*;
import java.awt.*;
import javax.swing.*;

public class Palindrome extends JApplet {
Font f = new Font("Times New Roman", Font.BOLD, 36);
Color color = new Color(25, 200, 144);

public void paint(Graphics g) {
getContentPane().setBackground(Color.black);
g.setColor(Color.white);
g.drawString("Hello World", 30, 30);
}
}

the problem is that nothing shows up until the screen is resized?

strange...

i tried everything, this is the closest i got to it...

small question: JApplet seems to copy the last page when repaints... does this mean that problem will go away if i set a background color?

ess
12-26-2007, 09:09 PM
This behaviour can be caused as a result of using the <APPLET>....</APPLET> tag, specially in IE6,7 browser(s). For more info, please see http://www.w3.org/TR/html4/struct/objects.html

You should use the <OBJECT>...</OBJECT> tag instead. Please see http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/using_tags.html#object for more information.

Let's know if this solves the problem or not.

Cheers
~E



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum