Monday, June 21, 2010

Images in NetBeans Swing Applications



I was trying to create a setup package for a software created by someone with NetBeans yesterday. The guy put the images in the NetBeans project directory but not in a package. Everything run fine on his system since the images were created on the various JPanels and JLabels using absolute path. I run it on my machine and booom. The images were not showing. I went back to correct the problem. Absolute paths are the worst thing a programmer should do in development. NetBeans has made our lives so easy we just click, drag-and-drop and everything happens.
The moral of the story - Adding images for platform independence in NetBeans should be done in packages. The best thing in my opinion is to put all the images in an images folder, copy and paste in NetBeans default package for the project in question. Just click the component with which you seek to add images and look up for its Icon property in NetBeans. Use Image Within Project option to browse for images in the project's directory.
If you want to use an External Image it is best to Import to Project for easy accessibility. Note either is a programmer's choice.
What I do most often is create a package for images so that when I package the software, I need not copy a single image. They get embedded in the jar file.

Monday, April 5, 2010

Sexy NetBeans


New to Java? I would recommend no other IDE than NetBeans. NetBeans IDE is the best one kind find using in creating crazy java applications. It makes life easier for programmers of all levels. I always feel strangled or suffocated when I jump into other IDEs.
The developers of NetBeans IDE used the K.I.S.S (Keep It Stupidly Simple) approach in development.
The sexy features in NetBeans just drives me crazy when I start off any project. I now call myself a logic programmer since all the graphical user interfaces (GUI) are just a click away. Why waste your time and energy coding GUIs when you can click. My slogan now in java development is "Click your way through".
I have tried other IDEs and as I said earlier they are no match to NetBeans. Have any questions on the usage of NetBeans? Just post them and I will be available to answer.