在Java代码中以代码名称添加图像 [英] Adding image in java code in code name
问题描述
我是代号为1的新手。我必须在具有特定宽度和高度的容器(流布局)中添加图像。
I am new in code name one. I have to add image in a container(flow layout) with specific width and height.
1:codenameone的指南说我们必须在资源文件夹中添加图像。资源文件夹在哪里?
1: codenameone's guide says that we have to add image in resource folder. Where is that resource folder?
2:要创建图像,我正在使用图像类的createImage(path)。如果将图像文件放在资源文件夹中,那么该图像的路径是什么。
2: To create image i am using createImage(path) of image class. if we put image file in resource folder then what is path of that image.
3:这里是图像文件的任何类型限制吗?
3: Is here any type restriction of image file in it.
请帮助。
推荐答案
当您放置图片时,您想在src中添加文件夹中的代码应如下所示:
When you put the image you would like to add in your src folder the code should look as followed:
标签i = new Label();
Image img = Image.createImage( / imageToAdd.png);
i.setIcon(img);
您可以将标签更改为想要用来显示图像的任何对象
You can change the label to whatever object you would like to use to display your image.
这篇关于在Java代码中以代码名称添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!