C
ChristianZ
Gast
Hi! Wie kann ich bei einem Click auf einen Button das Bild im Button ändern?
JButton button = new JButton(new ImageIcon("unselected.gif"));
button.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
JButton button = (JButton)me.getSource();
button.setIcon(new ImageIcon("selected.gif");
button.repaint(); // oder einfach repaint() aufrufen ?
}
});
void setDisabledIcon(Icon disabledIcon)
Sets the disabled icon for the button.
void setDisabledSelectedIcon(Icon disabledSelectedIcon)
Sets the disabled selection icon for the button.
void setIcon(Icon defaultIcon)
Sets the button's default icon.
void setPressedIcon(Icon pressedIcon)
Sets the pressed icon for the button.
void setRolloverIcon(Icon rolloverIcon)
Sets the rollover icon for the button.
void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
Sets the rollover selected icon for the button.
void setSelectedIcon(Icon selectedIcon)
Sets the selected icon for the button.