• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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

 
Ranch Hand
Posts: 62
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.









screenshot-JFrame.JPG
[Thumbnail for screenshot-JFrame.JPG]
screenshot
 
Bartender
Posts: 825
5
Java Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohammed Azeem
Ranch Hand
Posts: 62
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou.

Very helpful answers.

It is resolved.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!