Hello. I'm writing an RMI application for my semester project, and I'm getting a really frustrating error! I have the interface PlugNPlayIMPL that contains 5 or so abstract methods. One method (init) is called and it creates a new JPanel in the class that was bond to the registry. Here's the problem: I'm trying to paint to the panel, but when I call <JPanel>.getGraphics(), it throws a null pointer exception. I'm checking beforehand to make sure that the JPanel has been created too... Does anyone have a solution/explanation?
llemes4011 31
Posting Whiz in Training
Recommended Answers
Jump to PostHello,
Please post the code related to the problem so we can check and help you on it.
Still...
You are using JPanel.getGraphics() to get the Graphics object to draw on. You should be drawing only within the paintComponent() method using the graphics object supplied as the …
Jump to PostOkay, but when I override paintComponent, it gives me an error...
It works if I don't override paintComponent (as in it doesn't throw any errors, but nothing is painted...)... why's that?
Code (The class that is having problems, the other class calls init and start game)
package server; …
All 8 Replies
puneetkay 40
Junior Poster
llemes4011 31
Posting Whiz in Training
llemes4011 31
Posting Whiz in Training
puneetkay 40
Junior Poster
~s.o.s~ 2,560
Failure as a human Team Colleague Featured Poster
llemes4011 31
Posting Whiz in Training
~s.o.s~ 2,560
Failure as a human Team Colleague Featured Poster
llemes4011 31
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.