Not necessarily, none.png is written to indicate, that there is not an actual picture behind the img.
The setImage() method is called to overwrite the img component that is linked by the id=liveImage2.
Hence, if you do not put the setImage() method in the openView method, there will not be any image in your UI, irregardless that the img component was linked to the right picture.
Anyway, I was wondering if it is possible to set an image as background, and in such a case what would be the correct size of the image (having in mind the tablet application and not just the simulator).
Hello,
I’m getting a NoClassDefFoundError when I try to use ImageIO. I know that class is included in rt.jar from jvm libraries, but apparently the classpath of the URSim environment doesn’t include it.
How can I add that jar to my classpath in this environment? I couldn’t find a way to embed this jar in my urcap either.
Does anyone know what I’m missing?
I just figured it out.
For the record, I used LabelComponent in Java and label as HTML tag, and I added a border="0" attribute to the tag.
I tried the same with the img tag, but it didn’t work.
Hi! I’m having troubles to include an image, I’m using ImageIcon function, I’m not sure what the problem is. Here is my code:
JLabel jIcon = new JLabel();
ImageIcon imgIcon = new ImageIcon(new ImageIcon("/com/ur/urcap/helloworld/impl/Logo.png").getImage().getScaledInstance(150,51, Image.SCALE_DEFAULT));
jIcon.setIcon(imgIcon);
In URSim I already can put my image by putting the Location in my computer but the problem is when I want to put it on the teach pendant’s screen. I’m running out of options so if you have any suggestion or you know where the problem is I’ll be thankful in advantage.
@slvdr05
To add images in a swing based URCap I do the following:
public JLabel imageLabel;
BufferedImage image = ImageIO.read(this.getClass().getResource("image.png"));
imageLabel = new JLabel(new ImageIcon(imageLabel));
This will store your image in the JLabel imageLabel. Add this to your GUI as you would any other JLabel
This relies on your image (here called image.png) saved under src/main/resources.
As getResource() will return an object from within the resource-folder of your bundle (URCap / JAR).
While a “static” use of /com/ur/... will point to a location in the root file system.
Where exactly in the code are these lines? I’m having trouble getting this to work, I put the lines in a function SetLogo() in the program node view, which is then called from openView() in the contribution.
@ianc1
That code looks fine to me, make sure you’ve run setLogo() from within buildUI() and then added imageLabel to the JPanel passed as an argument in buildUI().