wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes JFrame background seems to be a picture of the desktop - why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame background seems to be a picture of the desktop - why?" Watch "JFrame background seems to be a picture of the desktop - why?" New topic
Author

JFrame background seems to be a picture of the desktop - why?

Mohammed Azeem
Greenhorn

Joined: Aug 17, 2012
Posts: 12
Good Morning Everyone,

Still a greenhorn but stepping up to coding my own "experiments".

This little Java program works but the JFrame's background seems to be that part of the desktop where the window happened to be located when it first appears.
Dragging the JFrame to a different lccation and then "damaging" it by minimising - maximising, changes the background but its still a picture of the desktop at that location.

A snapshot of the JFrame is attached.

The design of this little program is: (all three classes are listed below):

* Class MyDrawing. Defines an oval centred at a specifed point and specified width and height.
The oval is drawin onto a Graphics object

* Class ArtFrame. A constructor of this class accepts a MyDrawing object as a parameter.

* Class ShowFrame. The entry point into the program. Contains the main method.

Any help is most appreciated.

Thanks.












[Thumbnail for screenshot JFrame.JPG]

Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

You are missing super.paint(g) in your paint method of ArtFrame class. Add it as a first statement of the method, and it should work properly.


The quieter you are, the more you are able to hear.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

Rather than doing that, don't perform custom painting in a top level window. Learn how to do it the correct way here: Performing Custom Painting.

Also learn to respect Swing's single threaded rule: Concurrency in Swing. All Swing methods and constructors should be called on the EDT.


luck, db
There are no new questions, but there may be new answers.
Mohammed Azeem
Greenhorn

Joined: Aug 17, 2012
Posts: 12
Thankyou.

Very helpful answers.

It is resolved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame background seems to be a picture of the desktop - why?