Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Doubt in AWT

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks,
Please explain me this unexpected behaviour.

When I run this code nothing is visible but I expected a button
occupying the entire frame. but to my surprise I found that
a blank frame with the size appeared. But when I resized the frame manually the button came with a splash..surprising.
Also when I change the order of setVisible and setSize it comes
correctly. Why does the order of specification play a role here.
Can anybody please explain

------------------
Regards,
V. Kishan Kumar
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try your codes but it works fine on my machine. If I set the frame visiable before I set the size, I can see the frame (very small) and then it expands to the specified size immediately.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kishan -
The default size of the frame is very small so when you do a setVisible() Java tries to display a tiny frame (just remove your setSize() and see). When you call setSize() the Frame changes size, but does not redraw it's contents unless specifically told to. (via setVisible() again) So, it's a good idea to call setSize() then setVisible().
BTW - try this code... it's pretty fun...

-Nate
 
reply
    Bookmark Topic Watch Topic
  • New Topic