About path problems in Image?

xiaoxiao2021-04-08  6


There is a Static CreateImage (String Name) method in the Image class.

Image i = image.createImage ("C: /Wtk22/APPS/f5/src/ack.png");

I use this compilation error,

Then change to image i = image.createImage ("/ Ack.png");

Compile, but when running, it will appear.

(Ack.png file has existence).

How to change it for help?


It should be understood that different IDEs are different for the path setting method, such as Eclipse and NetBeans.



Here is an Eclipse as an example:

first step:

Establish the SRC source folder and the RES resource folder, the method is: Window -> Preferences -> Java -> Build Path, "Source and Output Folder" Select "Folder", make sure "Source Folder Name" is "SRC "," Output Folder Name "is" bin ", then" Apply "," OK "is turned off. Set the three folders of SRC, BIN, RES when you set up new projects, put the image file in the RES! Eclipse's default directory for resources is the res directory. If the Ack.png is placed in the restendate, the above description is correct; if you create an image directory in the RES directory to store Ack.PNG, the path in the above program should be "/Image/ack.png "

Step 2:

You must remember that if you copy the PNG image to the RES folder, if you don't display it in the IDE, you must right-click the project name, then

Refresh can appear.

If the above method is not used to divide the exporter folder, the resource folder and other folders, the PNG picture we use should be placed in the root root directory, and pay attention to a certain refresh project, which is the package, these image files It can be hit in the JAR package, and of course you can also define a folder to the PNG image, which also needs to modify the file path in the program.

In addition:

On the NOKIA6230i, when the icon of the list item is displayed, the icon size is 24 * 24 is relatively appropriate.

In addition, when a list item is displayed: The icon file of the list item can also be a GIF file.

转载请注明原文地址: http://www.9cbs.com/read-132834.html

New Post(0)