1、创建一个JButton对象,并使用addActionListener()方法为其添加ActionListener。2、在ActionListener中编写响应事件的代码。3、在代码中使用isSelected()方法来检查按钮是否被选择。如果按钮被选择,则该方法返回true,否则返回false。