moin, ich hab da n problem mit meinem applet Oo
ich hab ne klasse "Test", die im moment nur ein bild anzeigen soll.das bild ist ein teil eines objektes von meiner anderen klasse "MyCursor".aber ich bekomm immer ne nullpointerexception ôo
hier der code:
import java.awt.*;
import java.applet.*;
public class Test extends Applet
{
int width, height, counter;
MyCursor mycursor;
public void init()
{
width = getSize().width;
height = getSize().height;
setBackground(Color.white);
MyCursor mycursor = new MyCursor();
mycursor.x = 0;
mycursor.y = 0;
mycursor.cursor = getImage(getCodeBase(),"pics\\cursor\\cursor.jpg");
}
public void start()
{
}
public void stop()
{
}
public void run()
{
}
public void paint(Graphics g)
{
g.setColor(Color.black);
for (counter = 0; counter < 20; counter++)
{
g.drawLine(width, height-counter*31, 0, height-counter*31);
g.drawLine(width-counter*31, height, width-counter*31, 0);
}
g.drawImage(mycursor.cursor, mycursor.x, mycursor.y, this); // hier sagt er nullpointerexception...
}
}
Alles anzeigen
komplette fehlermeldung:
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at Test.paint(Test.java:35)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301)
at java.awt.Component.dispatchEventImpl(Component.java:4489)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
kann mir wer sagen woran das liegt?