Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI Example (HFJ)

 
Mikpo Siru
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The code from page 371 makes a JFrame, inside of which is a button and a custom widget. The custom widget fills the background black, and also draws an oval whose colour changes randomly when the button is pressed.



What I don't understand is how the custom widgets' width and height attributes are being updated with the JFrames size - even as I resize the frame, becuase I haven't assigned anything to the attributes in code.

Thanks

MCU
 
Rob Camick
Ranch Hand
Posts: 2616
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you added your panel to the CENTER of a BorderLayout. The panel is automatically resized to occupy all the spaces available to the panel.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic