The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Doubt in AWT" Watch "Doubt in AWT" New topic
Author

Doubt in AWT

Kishan Kumar
Ranch Hand

Joined: Sep 26, 2000
Posts: 129
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


Regards,<BR>V. Kishan Kumar
bante
Greenhorn

Joined: Jun 19, 2000
Posts: 11
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.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4120

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


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
 
subject: Doubt in AWT
 
Threads others viewed
AWT Question.......help please!
for jqplus team
Exception
windowlistener
Error: Exeption in thread "main" java.lang.NoSuchMethodError: main