This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic problem with painting of component  RSS feed

 
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!