Hi, I am trying to have a jpg show up as the background of a JFrame, the user can then click on parts of that image and depending on the mouse position methods are called.
I have tried to add the background by extending JFrame:
The frame is created with
mainFrame is created and works fine, I can add components and whatnot - but the background is grey as ever. When I change the size of the frame (I mean by draging the corner of the frame, not within the code) the background flickers a bit and I can see that the jpg is there, it just doesn't show. I've tried setting the background to null, but that just makes MyFrame use the default background inherited from JFrame - so nothing happens.
I would appreciate your help.
The problem people have in trying to create something foolproof is that they generally underestimate the inginuity of fools.
I really urge you to follow the instructions in the private message Amit sent you. It is not optional, and failure to comply will lead to the closing of your account.
Other than that, you're missing calls to super.paint(g) and super.update(g); omitting these will mess up your user interface with older drawings remaining. And that's not just the image, but also the border.