Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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
 
You showed up just in time for the waffles! And 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
reply
    Bookmark Topic Watch Topic
  • New Topic