This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes weird resizing of applet window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "weird resizing of applet window" Watch "weird resizing of applet window" New topic
Author

weird resizing of applet window

John Wickerson
Greenhorn

Joined: Mar 16, 2006
Posts: 13
Hey guys,

When I start my applet with appletviewer, I get a white window saying "Hello".
When I make my applet window bigger, I get a blue/grey window that is blank.
When I make my applet window smaller, I get a blue/grey window that says "Hello".

What is the reason for this strange behaviour? I simply want "Hello" to be always positioned in the middle of the screen.

Here is my code:


Thanks for any suggestions you may have...

John
Matti Poro
Ranch Hand

Joined: Dec 03, 2005
Posts: 41
JApplet's content pane is painted on the JApplet. http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Do read the link above, but I'll summarize by saying that in Swing (dealing with any component whose name starts with a J) you never override paint(Graphics) but rather only paintComponent(Graphics), and even then, always call super.paintComponent(). Overriding "paint()" on a JApplet makes all kinds of bad things happen!


[Jess in Action][AskingGoodQuestions]
John Wickerson
Greenhorn

Joined: Mar 16, 2006
Posts: 13
Thanks guys!
 
 
subject: weird resizing of applet window
 
Similar Threads
Running applets
how to convert a bufferedImage into a string
simple applet won't run
Simple question on Applet
NoClassDefFoundError when trying to run an applet