Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

applet background

  Asked By: Ryan    Date: Sep 04    Category: Java    Views: 740
  

I want to change my applet background. I use "this.setBackground(new
Color(20,80,120))" in init method and also in start method. But I
just see this color in my applet background for a moment in inited
applet time and after that I can't see this color.what is the problem?
Can I use an image for my applet background?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Orville Rodriguez     Answered On: Sep 04

Override paint method and then set background  color inside it.
The code looks like this:

@Override
public void paint(Graphics g) {
super(g);
Graphics2D g2d = (Graphics2D) g;// optional but useful
...
this.setBackground(Color.RED); //or whatever you prefer
...
}

I hope it will help.

 
Didn't find what you were looking for? Find more on applet background Or get search suggestion and latest updates.




Tagged: