• 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
Sheriff
Posts: 24215
37
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!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!