Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Unhappy applet background paint

    I have an applet which has an imageBackground which simply paints an image. On the applet I have a form with some checkboxes. When I scroll my mouse over the checkboxes, it paints the background in the word part of the checkbox. It only does this on a couple of machines and I can't figure out why. I've cleared my cache and everything else on mozilla and I still get the same problem. Here is my image panel

    public class ImagePanel extends JPanel{
    BufferedImage image;

    public void setImage(BufferedImage i){
    image = i;
    }
    public void removeImage(){image = null;}
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    if(image != null)
    g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
    }
    }

    Or you can check it out at beancitycoffeeco.com

    Any help would be greatly appreciated

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I can't get into your applet on the site. Would setting your JCheckBox's opaque property to true fix your problem?

  3. #3
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default

    My checkboxes are set to opaque. That's weird that you can't get in. I know that 20 others can. Should I try updating java. I downloaded it a few months ago

  4. #4
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default

    oh wait. They weren't opaque. I'll try it

  5. #5
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default

    so. I get the same problem. It now just repaints my background faster and more often

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    Applet or JApplet? Don't mix AWT and Swing components.

    db

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    It only does this on a couple of machines
    The behavior resulting out of mixing AWT and Swing components changed some time between 6u2 and 6u17. I only noticed it recently when I ran an old code where I had knowingly and purposefully used both AWT and Swing components. That could explain your observation.

    db

  8. #8
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default

    I'm running JApplet. Sorry. I'm not mixing awt and swing. only using swing

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    To get better help sooner, post a SSCCE that clearly demonstrates your problem.

    Use code tags to post codes -- [code]CODE[/code] will display as
    Java Code:
    CODE
    db

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  11. #11
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default

    I'm sorry i multi-posted. I just wanted this on the new java forum too, so more people would see it because It doesn't seem like anybody can answer me here. As for the sscce, you don't want my entire code, it's huge. But it's basically just a form which some JCheckBoxes, JtextFields, JButtons and JLabels and JComboBoxes.
    I've already posted the code for my image panel up top and I simply replace the content pane of my main JPanel with the image panel. The background shows up fine. It's just the JCheckBoxes that want to repaint the background in themselves. And again. You can see it at beancitycoffeeco.com. trust me, its there

  12. #12
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default

    private JCheckBox addCheckBox(String name, int x, int y, int width, int height){
    JCheckBox jcb = new JCheckBox(name);
    jcb.setForeground(fontColor);
    jcb.setBounds(new Rectangle(x, y, width, height));
    //jcb.setOpaque(false);
    cp.add(jcb);
    flavorList.add(jcb);
    return jcb;
    }

    Here's the JCheckBox code just in case

  13. #13
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by footballHunter View Post
    I'm sorry i multi-posted. I just wanted this on the new java forum too, so more people would see it because It doesn't seem like anybody can answer me here.
    It's OK to cross-post as long as you notify all threads that you've done this with links. As for the multi-posts, that risks different forum members answering the same questions, duplicating effort of a volunteer. I greatly appreciate your apology and your agreeing to not do this again. Thanks.


    As for the sscce, you don't want my entire code, it's huge. But it's basically just a form which some JCheckBoxes, JtextFields, JButtons and JLabels and JComboBoxes.
    I've already posted the code for my image panel up top and I simply replace the content pane of my main JPanel with the image panel. The background shows up fine. It's just the JCheckBoxes that want to repaint the background in themselves. And again. You can see it at beancitycoffeeco.com. trust me, its there
    We don't want to see the whole code. Again the SSCCE link will explain what we need. Regardless I went to beancity... but couldn't download your code. Anyway, if you create a small SSCCE that is compilable, more folks will be able to help you and likely quickly.

    BTW, in your posted code, I don't see where you set the opaque property of the JCheckBox to true.
    Last edited by Fubarable; 11-24-2010 at 11:00 PM.

Similar Threads

  1. Background Image of Applet
    By BangJava in forum Java Applets
    Replies: 8
    Last Post: 11-24-2010, 05:48 AM
  2. Replies: 10
    Last Post: 09-17-2010, 04:04 AM
  3. Paint Program Help
    By ngiannini in forum AWT / Swing
    Replies: 12
    Last Post: 05-10-2010, 04:24 PM
  4. Doing a background job and not stall whole applet
    By becool007 in forum New To Java
    Replies: 2
    Last Post: 10-03-2009, 06:09 AM
  5. Replies: 1
    Last Post: 03-31-2009, 05:04 PM

Posting Permissions

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