This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

GUI Example (HFJ)

 
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
 
Rancher
Posts: 3205
29
  • 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.
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic