Cropping Images In Java

You can create an ImageIcon object in order to use an image with png, gif , jpeg extensions from an external source as shown below:
ImageIcon imageicon = new ImageIcon(“dir1/dir2/…/a.gif”);

and you can put it on any component for example on a label

JLabel label = new JLabel(imageicon);

On the other hand , sometimes you need  part of an image. The solution is below:

ImageIcon icon = new ImageIcon(“image.PNG”);
image = icon.getImage();
image = createImage(new FilteredImageSource(image.getSource(),
new CropImageFilter(x,y, w, h)));

x, y, w, h are integer variables declaring how to crop the image.

x is the upper left x coordinate of the image where you want,

y is upper left y coordinate,

w is width of image what you want,

h is height of the image what you want.

Benefits of Socialising

In many steps of the life we need to see people around us to feel happy. It does not matter what you are doing or what your job is our personal network determines our life standards, culture, power etc.

A good article about personal network from a software developer … I offer you to read this.

Serialization In Java

Every object in java which implements Serializable interface can be converted into a byte array and can be stored in a file on the disk . This object then can be read from that file on any platform. For example you can read an object which you created on windows platform in linux platform. You dont need to think any detail about the data. Java’s platform independency brings this advantage. Object serialization has a wide range use on our applications. The serialization is especially used with java beans. While a bean is used its configuration data is assigned generally in design time. Thus, this data must be stored in anyway and must be directed to bean when program started. Object serialization does this.  Lets look at how to do this in java. The objects we want to serialize must be member of a class which implements Serializable interface.

Read the rest of this entry »

How to open, extract and convert rpm files to deb files

Converting rpm files to deb files
Install alien
1)sudo apt-get install alien
Convert rpm to deb
2)sudo alien file.rpm
It creates file.deb in the same directory
To install deb files
3) sudo dpkg -i file.deb
or double click on the file.deb
Extracting rpm files withour using alien
rpm2cpio package.rpm | cpio -dimv

A powerful gui builder, jigloo

Nowadays, I am trying to develop a java applet which has a complex gui. I dealt with layouts and discovered gridbaglayout to develop complex guis. With gridbaglayout you create GridBagConstraints objects and assign that objects’ fields and add the component with related GridBagConstraints object to the container. You can learn it detaily from here. Though it is the most flexible layout of all , determining the field values is too difficult to create the desired gui. If you deal with .net it is so easy to develop graphical user interfaces. I always wonder why java does not have a gui builder tools except netbeans gui ide. And today i learned jigloo gui builder which is an eclipse plugin. Jigloo has many advanced features than netbeans gui tool.

  • It lets you change the variable names.
  • It writes simple code.
  • It does not restrict you not to change the code.

You can download its non commercial version from here .