Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

what does "addNotify" really do ???

Posted on 1997-10-23
1
Medium Priority
?
322 Views
Last Modified: 2008-02-26
Hi,

Can someone explain to me what does the "addNotify()" command do
in Panel (or Applet).

I have a problem in NT platforms. My applet does not refresh an
 inner layed canvas. The same applet works fine on Unix and Win95
 platforms.

 Only when i added "addNotify()" to the applet start()
  it solved the refresh problem.
 But, to my poor luck it caused a SEGMENTATION FAULT(!) both in the
 Unix appletviewer and Netscape 3.0.

thanks,
Avi Kavas.
0
Comment
Question by:kavas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
gwalters earned 150 total points
ID: 1229477
The addNotify() method creates a peer for the given component.  A peer is a class which is responsible for the appearance of that component (where the component itself is responsible for its functionality).  Peers are usually (but don't have to be) native code.  It's really just a way of separating function from appearance (so a TextField, for example, functions the same on Unix and Windows, but it's appearance is platform-dependant).

Here is the addNotify() method from the Panel class:

public syncronized void addNotify() {
  peer = getToolkit().createPanel(this);
  super.addNotify();
}

You should never have to call addNotify() directly.  The fact that it fixed your problem is most likely a coincidence.  However, I can't imagine that calling it would cause SEGMENTATION FAULT.

One thing is that, if the start method never returns, the applet will never be shown.  This is because the browser calls start() and then show() on the applet.  It's a good idea to only do simple setup in the start() method and return.  If you really need a running thread for the life of your applet (most really don't: they just process events), then you can implement Runnable, and put all that code in the run() method.

Or you can call show() yourself, but it's still not a good idea to stay in start() indefinitely.

Sorry for the rambling!


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question