• Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic problem with painting of component

 
guenter krannich
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will be boring for most of you but I simply don't get it:
I want to paint a JComponent of my own so I did this from what I understood:

But only the button is shown not my rectangle.
What did I miss?
Grateful for your help
Guenter
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Figur component's size is (0, 0), you could override getPreferredSize, getSize or getBounds for free component placement. Or just use setters.
 
guenter krannich
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mikko Kohtamäki wrote:Your Figur component's size is (0, 0), you could override getPreferredSize, getSize or getBounds for free component placement. Or just use setters.

Thanks Mikko!
Using setters worked, overriding getPreferredSize, too, although the resulting layout is different.
Overriding getSize and/or getBounds didn't make a (visible) difference.
Craig Wood wrote:skip frame.pack

Thanks Craig,
but this didn't show a better result!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!