JButton Formatting and Image Transparency

I have a JScrollPane, containing a JPanel on which buttons are added. its basically A scrollable Panel on which buttons are added.

I have 3 probelms in my Project

1. Basically The alignment of text on the button is too close to the left border of the button. How do I set the alignment of text so that there is a significant gap between the left margin of the button and the text.

2. Also I am adding "check marks" ImageIcons dynamically to the button based on some conditions. These checkmarks are similar to that used in JCheckBoxMenuItems. How do I set the image transparent so that It appears uniform accross all Look and Feel combinations. The image is just a check mark (A small tick)

3.Also When I hover or move my mouse over each of the buttons in the panel, a menuitem like blue background should appear on the button below the mouse pointer. Indicating the current selection

The limitation of my assignment is I cant use a JMenuItem or JCheckBoxMenuItem

Message was edited by:

hemanthjava

[1063 byte] By [hemanthjavaa] at [2007-11-26 18:52:11]
# 1
1. JButton.setMargin2. Use a transparent image for the icon. (BufferedImage.TYPE_INT_ARGB)3. Add a mouse listener to the button, on mouseEntered change the background color of the button, on mouseExited change the background back to the original.
Rodney_McKaya at 2007-7-9 6:26:12 > top of Java-index,Desktop,Core GUI APIs...
# 2

I have added the following listener

this.addMouseListener(new MouseAdapter(){

public void mouseEntered(MouseEvent e) {

XCheckedButton.this.setBackground(new Color(8, 37, 105));

XCheckedButton.this.setForeground(Color.WHITE);

}

public void mouseExited(MouseEvent e) {

XCheckedButton.this.setBackground(null);

XCheckedButton.this.setForeground(Color.BLACK);

}

});

setForeground does not seem to work. I want even the text color to change and hence its use. Is it the right way to handle forground text colour

hemanthjavaa at 2007-7-9 6:26:12 > top of Java-index,Desktop,Core GUI APIs...
# 3
Sorry ! Its working fine sir.
hemanthjavaa at 2007-7-9 6:26:12 > top of Java-index,Desktop,Core GUI APIs...