Hi,

If you trace through paint(Graphics g) and paintComponent(Graphics g), it shows what code is executed and when. You may also want to trace doLayout() if writing custom layout code. Don't forget super.methodName(params) or you may not activate the events for the specific thing you are doing, whether event processing or painting.

You may use: tecreations.ca/java/downloads/release/tecreations-0.4.0.jar to facilitate your os/network/image/text operations. That jar contains many examples of using the Swing and AWT classes together for whatever you need.

Of particular interest may be: CaptureTool, Deploy, Launcher? SystemCompiler for SystemTray use?

It should launch with double-click on Windows or 'java -jar tecreations-0.4.0.jar'. Run the Launcher, go from there.


Tim


On 2023-03-09 8:05 p.m., Dwayne Murphy wrote:
Hi everyone,

I have a simple project in java / maven  in apache netbeans.

I have a JFrame with a label that I have been trying to add an image to.

I continually get this error when the program tries to add the image to the label:

*_Cannot invoke "java.net.URL.toExternalForm()" because "location" is null_*


I have tried using the image selector, as well as custom code options. I have tried all the advice from stack overflow --- and I simply can't figure it out. I must have spent 3-4 hours --- and I'm about to give up.

Can anyone tell me why its so difficult to add an image to a JFrame?  Is there a simple way to do it? Am I missing something?

PS: This link seems to be a great resource for my problems... but I'm still getting the error!
https://netbeans.apache.org/kb/docs/java/gui-image-display.html


--

Dwayne Murphy
"Carpe Diem"
Hons B.Computer Science, B. Ed, Hons B.Commerce
Holy Names High School - Science, Business & Civics

Holy Names: 519-966-2504
Cell Number: 519-995-6915

Reply via email to