easy java image Box, my way
Hi there,
I believe that a lot of new comers found it hard to use images in JAVA, especially who came from .Net world. So I decided to simplify things out by providing this simple tool.
I call it imageBox to make it sound like VB Picture box. this imageBox is a hacked version of JPanel.
All what I did, is just overriding paint (Graphics g), after that I force it to load the Image file and draw it on the component itself.
ImageBox is a very useful tool; you may add it to netbeans palette. This allows you to change images from design level from imageFile property. note: in current version, just container will be shown, and image will not shown at design time.
to assign the image file you may need to use URL for the path, or a string:
getClass ().getResource (“/imgFolder/imgFile.jpg”)
or
“/imgFolder/imgFile.jpg”
note: it is better to include image files with the project source, you could group them in folder called “img”.
steps to add imagebox into netbeans project:
- create a new project with JFrame
- add imagebox.java to your project
- build your project
- drag imagebox.java on JFrame, it will show a box with “X”
- go properties -> imageFile, set file path as mentioned above.
Feel free to contact me for any help.
download: imagebox(0.0.6)
download: imagebox(0.0.5)
download: imagebox(0.0.3)example

May 28, 2009 - 3:54 pm
nice component, i just drag it on jframe and it works like magic. still it needs to support design time image rending.
June 12, 2009 - 10:14 pm
Great post! I’ll subscribe right now wth my feedreader software!
June 17, 2009 - 3:11 am
You have very good site!
In saecula saeculorum