Mr Raghavendra nandavar, this is what the example tried to demostrate: in paintComponent(Graphics g) one can just as easily put images (g.drawImage(some image,...)) or paint lines, ellipses, rectangles,... Mouselistener's mouseClicked method to fire an Actionevent, which is what one normally expects from a button... MouseListeners mousePressed and mouseReleased were used to show the user he touched the custom button
May be you could take some time to make a (abstract) generic custom button ( with the method paintComponent(g) abstract) and each time you want a special button, you extend this generic button: you just have to tweek paintComponent(g) to whatever your fantasy dictates. This is not working, this is art and fun!
KEEP IT IN A SAFE PLACE!!!
Here a ovalbutton:
And here and imageButton
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop