Is your code throwing an error?
customGroup.setIcon((Icon) new ImageIcon(getClass().getResource("/images/lv_32.png")).getImage());
This line is guaranteed to fail but it's getting past the compiler because of the explicit cast. I think you meant:
customGroup.setIcon(new ImageIcon(getClass().getResource("/images/lv_32.png")));
I tried it with DefaultPaletteItemGroup as well and get the same result.
I don't know what to tell you; it works on mine.
CustomPaletteItemGroup customGroup = new CustomPaletteItemGroup("LV Control");
customGroup.addPaletteItem(new JavaBeanPaletteItem(PMILabel.class));
customGroup.setIcon(IconUtil.getIcon("businesspeople"));
addGroup(customGroup);
1 Like
I got it to load the "businesspeople" icon, but how do I get it to load an icon from the same folder as where the components get their icons from?
In other words, I put the desired icon in the same directory as the "Hello World" component icon.
IconUtil.getRootIcon(java.lang.String path)
is defined as Loads the image found at /images/{path}
So I tried the IconUtil.getRootIcon(java.lang.String path)
as follows, but still without luck
PaletteImpl palette = (PaletteImpl) sdk.getPalette();
DefaultPaletteItemGroup group = new DefaultPaletteItemGroup("LV Control");
group.addPaletteItem(new JavaBeanPaletteItem(HelloWorldComponent.class));
group.addPaletteItem(new JavaBeanPaletteItem(BinComponent.class));
group.setIcon(IconUtil.getRootIcon("lv_16.png"));
palette.addGroup(group);
All of your code snippets have referenced a PNG file yet your screenshot shows a BMP file. Do you have the correct file name?
1 Like
Wow. All that headache because of a mismatching file extension
Thanks for bearing with me through this, it finally works.
1 Like
Here is the final code:
PaletteImpl palette = (PaletteImpl) sdk.getPalette();
DefaultPaletteItemGroup group = new DefaultPaletteItemGroup("LV Control");
group.addPaletteItem(new JavaBeanPaletteItem(HelloWorldComponent.class));
group.addPaletteItem(new JavaBeanPaletteItem(BinComponent.class));
group.setIcon(IconUtil.getRootIcon("lv_16.png"));
palette.addGroup(group);
1 Like