In my application, I would like to use the format in my application like as follows
I want simple code for either using JButton or JLabel. I 've used JLabel due to its aligment properties which looks good but JLabel doesn't have action listeners to perform some operations. If i use JButton then I m not able to align the same i've mention above user left side image then afterwards user_name. Using button, there is gap between image and user_name which looks bad.
Is't there any other components which is very easy to implement except JTree.
Using button, there is gap between image and user_name which looks bad.
Personally, I think it looks good. White spaces exists for a reason. Take a look at the browser you are using. I bet all the menu items or toolbar buttons have a gap between the icon and the text. The UI designers of IE have more experience than you do.
But if you really want to proceed, then read the JButton API you will find a method that allows you to control the icon/text "gap".
subject: Problem in alignment of its text in JButton with its image