Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

weird resizing of applet window

 
John Wickerson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
John Wickerson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic