swapnel surade wrote:I have done,
JButton longButton = new JButton(new ImageIcon("c:/normal.png"));
longButton.setPressedIcon(new ImageIcon("c:/normalpress.png"));
longButton.setOpaque(false);
longButton.setBorderPainted(false);
longButton.setFocusPainted(false);
longButton.setBorder(new EmptyBorder(0,0,0,0));
longButton.setBackground(Color.blue);
following code, still I get the pressed look after pressing the button.
I dont want that effect which came after pressing the button (button is in pressed state)
First of all, pressing the button will cause the icon to change from normal.png to normalpress.png. If you don't want pressing the button to do that, then you shouldn't be calling setPressedIcon() [or
you should set the pressed icon to the same as unpressed]. So I presume that's not what you are asking.
If normal.png and normalpress.png are the same size and have no transparent pixels, then I don't understand how you would see any "effect which came after pressing the button" since you have gone to the unusual step of replacing the button's border.
If they are different sizes or normalpress.png has transparent pixels, then you will probably (depending on your LnF) see the background color change. You should be able to disable this by calling
longButton.setContentAreaFilled(false).