J
johnston_58
Hi,
I am trying to create a pushed button image for a button.
I cannot get the setPressedIcon() method to work for me.
I tried using the setIcon method for the button, but the icon shows up
with a grey border around it, however setPressedIcon() does work .
I have now tried the method below - the problem is that the
setPressedIcon() now won't work.
Does anyone know a way around this or have any suggestions?
Thanks in advance for any help.
Kind Regards and Happy Holidays,
Johnston
/****************** code ************************/
JButton bSend;
ImageIcon sendIcon = new ImageIcon("sendBtn.jpg");
ImageIcon pSendIcon = new ImageIcon("pSendBtn.jpg");
....
bSend = new NewButton("Send",sendIcon.getImage());
bSend.setPressedIcon( pSendIcon);
......
}
class NewButton extends JButton {
Image image;
public NewButton(String Text, Image Image) {
super(Text);
setOpaque(false);
image=Image;
}
public void paint(Graphics g) {
g.drawImage(image, 0,0, getWidth(), getHeight(), this);
super.paint(g);
}
}
/***************** End code *****************************/
I am trying to create a pushed button image for a button.
I cannot get the setPressedIcon() method to work for me.
I tried using the setIcon method for the button, but the icon shows up
with a grey border around it, however setPressedIcon() does work .
I have now tried the method below - the problem is that the
setPressedIcon() now won't work.
Does anyone know a way around this or have any suggestions?
Thanks in advance for any help.
Kind Regards and Happy Holidays,
Johnston
/****************** code ************************/
JButton bSend;
ImageIcon sendIcon = new ImageIcon("sendBtn.jpg");
ImageIcon pSendIcon = new ImageIcon("pSendBtn.jpg");
....
bSend = new NewButton("Send",sendIcon.getImage());
bSend.setPressedIcon( pSendIcon);
......
}
class NewButton extends JButton {
Image image;
public NewButton(String Text, Image Image) {
super(Text);
setOpaque(false);
image=Image;
}
public void paint(Graphics g) {
g.drawImage(image, 0,0, getWidth(), getHeight(), this);
super.paint(g);
}
}
/***************** End code *****************************/