Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jagged Drawing in Applet after refresh

 
chimby thompson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a little applet that allows someone to "sign" an e-document with the mouse, but the applet flakes out after a couple of page refresh's. Specifically, it is impossible to draw a straight line. It jumps all over the place and the result is a jagged mess of scribbles.

To reset the applet you have to close the browser and reopen (as far as I know).

Any thoughts?

thanks,
-dt

:::I have a small screenshot, but nowhere to post it. I can email it if anyone wants to see it.
 
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
Sounds like you are initializing things in the constructor or init() method that you ought to be doing in the start() method.
 
chimby thompson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm listening... I haven't used java in about 6 years, could you expand a bit?

-thanks.
 
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
When an applet is created, obviously the constructor is called. Then it is stuck into the web page, and init() is called. Then start() is called. When you browse away from a page, stop() is called. When you browse back, start() is called again.

So I'm imagining that there's something that should be initialized whenever start() is called, but instead you're initializing that thing in init() or in the constructor, so it's only done once. Alternatively, there could be something that you are doing in start() that should instead be done only once, in init() -- like adding new components.
 
chimby thompson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you might be on to something. Almost everything in this applet is done from init()...check it out:



I will see if I can move stuff into the start() method to see if that works. Thanks for the hint.

-dt
 
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
Mmmm, well, I don't think moving all that into start() necessarily makes sense, but it might be that you need to add some code in start() to reinitialize something or other. I'm (obviously) not familiar with the third-party library you're using or the protocol in use, but maybe some of them setTabletState(X) or clearTablet() methods need to be called from start() and/or stop(). Check out the documentation to see when and where these things are supposed to be called.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!