• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GUI Example (HFJ)

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic