Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder DELOCH's Avatar
    Join Date
    Apr 2006
    Location
    Canada
    Posts
    537
    Thanks
    4
    Thanked 2 Times in 2 Posts

    JApplet background color

    I have a problem with setting a background to JApplet

    my code:
    PHP Code:
    import java.awt.geom.*;
    import java.awt.*;
    import javax.swing.*;

    public class 
    Palindrome extends JApplet {
        
    Font f = new Font("Times New Roman"Font.BOLD36);
        
    Color color = new Color(25200144);

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

    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?

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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/...gs.html#object for more information.

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

    Cheers
    ~E


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •