JMenu doesn't go away when try to click off

I'm trying to put a .jpg, a couple menus, and 2 buttons on a JFrame.  I got the .jpg in there nicely and the two buttons on the bottom and I put the menus in.  I click on the menu or use a ALT+Whatever shortcut to open a menu and that works fine, but when I click again to make it go away, a sort of imprint of it stays on the screen, like it got painted there with the .jpg.  If you want to download the source code, it's here: http://www.geocities.com/thearchitect2/Tetrix.java.  You'll also need the .jpg which is here: http://www.geocities.com/thearchitect2/tetrix.jpg.  I think it has something to do with repainting the panel or something, but I don't know how I would do that.  Thanks a lot for the help!
thearchitect2Asked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
try this:

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        final int newX = getIntX()/5;
        final int newY = getIntY()/12;
        final int width = newX*3;
        final int height = newY*4;
        g.drawImage(logo,newX,newY,width,height,this);
    }    //close paint()
0
 
objectsCommented:
instead of overriding paint() you should override paintComponent()
0
 
thearchitect2Author Commented:
I had that in the first place, but then I switched them hoping paint() would work better.  What's the difference between the two?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
objectsCommented:
paint() is responsible for painting the component, it's children, it's border etc.
paintComponent() is just for painting that actual component.
0
 
thearchitect2Author Commented:
Ok, that's always good to know. I tried changing it back, but it still leaves the menu there and it doesn't disappear.
0
 
thearchitect2Author Commented:
Thanks a lot! It's exactly what I wanted!  If you have time, could you explain to me how that made it work? I'm kind of a novice at Java.
0
 
objectsCommented:
you need to ensure you paint all of the panels background.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.