JToggleButton反转按钮代码1

还是直接上代码吧。
public class JToggleButtonTest extends JApplet{
public JToggleButtonTest() {
Container contentPane = getContentPane();
ImageIcon icon = new ImageIcon("Login.gif");
final JToggleButton button = new JToggleButton(icon);

contentPane.setLayout(new FlowLayout());
contentPane.add(button);

button.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
int state = e.getStateChange();
String s;

if(state == ItemEvent.SELECTED) s = "selected";
else s = "deselected";

showStatus("Item Event: " + s);
}
});
}
}


展开阅读全文

没有更多推荐了,返回首页