Image implementation

Hello,

I’m currently trying to implement an image into the installation tab of my urcap (UR version 5.0.3),
whereby i followed this tutorial (using the label component variant):

But instead of the image showing, i get this error on startup:

Capture

This is the code i used (it is based on the mydeamon example):
label definition: (LogoImage)
label

This is the openview() code:

@Override
	public void openView() {
	    enableDaemonButton.setText("Start Program");
		disableDaemonButton.setText("Stop Program");
		popupTitleField.setText(getPopupTitle());


		//UI updates from non-GUI threads must use EventQueue.invokeLater (or SwingUtilities.invokeLater)
		uiTimer = new Timer(true);
		uiTimer.schedule(new TimerTask() {
			@Override
			public void run() {
				EventQueue.invokeLater(new Runnable() {
					@Override
					public void run() {
						updateUI();
					}
				});
			}
		}, 0, 1000);

        try{
            LogoImage.setImage(ImageIO.read(getClass().getResource("/com/ur/urcap/examples/mydaemon/impl/logo_transparent.png")));
        }
        catch (IOException e) {
            e.printStackTrace();
        }
	}

Html definition:
html

The image shows up in the correct folder in the built urcap:

But still this results in a nullpointer where it can’t locate the image.
Am i still missing something?
thanks in advance!

You cut off a significant part of error message window in you screenshot, I think. Are you sure the path to resource is ok?
Try to run Polyscope in terminal and see what kind of messages pop up.
Why not using <img> for image, btw?

EDIT: Ok, I think you didn’t put your image under .../src/main/resources/com/ur/urcap/examples/mydaemon/impl/logo_transparent.png. Am I right? You put it together with java source files. Maybe that’s the problem.

1 Like