Re: getAppletContext() Null pointer exception
- From: "Tester" <since_1979_007@xxxxxxxxx>
- Date: 23 May 2005 21:03:20 -0700
>Have you ever successfully opened a new window from an applet in a
normal web page in that browser?
Yes.
************************************************************************************
Here is the code of Applet A:
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.awt.Graphics;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;
import javax.swing.JPanel;
import javax.swing.*;
public class AppletA extends JApplet {
public void init() {
Display display = new Display();
setContentPane(display);
}
class Display extends JPanel implements AppletStub, MouseListener {
Graphics g = null;
Display() {
addMouseListener(this);
g = getGraphics();
}
public void init(){
repaint();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
}
public boolean isActive() {
return false;
}
public void appletResize(int width, int height) {
}
public AppletContext getAppletContext() {
return null;
}
public URL getCodeBase() {
return null;
}
public URL getDocumentBase() {
return null;
}
public String getParameter(String name) {
return null;
}
public AppletStub getAppletStub(){
return this;
}
public void mouseClicked(MouseEvent e) {
if(e.getModifiers()==InputEvent.BUTTON3_MASK) {
ContextMenu cm = new ContextMenu(e, getAppletStub());
cm.init();
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
}
}
*************************************************
I have changed the constructor of the ContextMenu again:
public ContextMenu(MouseEvent me, AppletStub stub){
e=me;
setStub(stub);
}
But when i use getAppletContext(), "Null pointer exception" again.
What should I do?
Thanks a lot!
.
- Follow-Ups:
- Re: getAppletContext() Null pointer exception
- From: Andrew Thompson
- Re: getAppletContext() Null pointer exception
- References:
- getAppletContext() Null pointer exception
- From: Tester
- Re: getAppletContext() Null pointer exception
- From: Andrew Thompson
- Re: getAppletContext() Null pointer exception
- From: Tester
- Re: getAppletContext() Null pointer exception
- From: Tester
- Re: getAppletContext() Null pointer exception
- From: Andrew Thompson
- getAppletContext() Null pointer exception
- Prev by Date: Re: static or not?
- Next by Date: Connection to MySQL Goes Away
- Previous by thread: Re: getAppletContext() Null pointer exception
- Next by thread: Re: getAppletContext() Null pointer exception
- Index(es):