• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inconsistent behaviour

 
Frantizek K
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused about the results produced by the following program.

The program initializes the screen ( by calling drwinit()) and then draws on the screen (over the initialization). The Thread kicker is used in animation of the screen. The boolean initflag is a boolean flag for the initialization of the screen.
The program, run as an application, works fine.
As an applet it works fine only once out of 10 times.
90% of time, the applet (run in appletviewer) initializes the
image on the screen ( the method drawinit() ), then ERASES the screen and draw on the empty screen. The other 10% of the time, the screen is not erased after the initialization.
My questions are:
1. Why the program exhibits this inconsistent behaviour when run as an applet?
2. How can I change it such that it will not erase the screen
after the mathod drawinit()?

[This message has been edited by Marilyn deQueiroz (edited September 06, 2001).]
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added code tags to help make your code more readable.

As far as I know, you do not need to call
theApplet.init();
nor
theApplet.start();
explicitly.

Typically you override start() to start or resume threads.
From the code you have provided, it seems that the screen should not be erased, but I don't see where you call the update() method.

Also, I would request that you re-register following the JavaRanch guidelines (See http://www.javaranch.com/name.jsp for more details).
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's highly questionable to make the paint() operation conditional. paint() gets called for a LOT of reasons. Any time that the GUI has reason to suspect that the client area has been corrupted - not just when data has changed.
A lot of windowing systems can avoid calling paint() for simple operations like moving someone else's window over yours because they cache your image as a bitmap, but sooner or later, paint() WILL get called. Don't depend on the windowing system.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic