aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem in alignment of its text in JButton with its image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in alignment of its text in JButton with its image" Watch "Problem in alignment of its text in JButton with its image" New topic
Author

Problem in alignment of its text in JButton with its image

ahmedali mohd
Greenhorn

Joined: Apr 14, 2010
Posts: 15
Hi all,


In my application, I would like to use the format in my application like as follows

User1
:User2
User3

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.

It is very urgent. Please let me know quickly
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2216
    
    7
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".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in alignment of its text in JButton with its image