Solved

what does "addNotify" really do ???

Posted on 1997-10-23
1
307 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 50 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

718 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