如果使用JButton,这很容易:
public class Test{ public static void main(String[] args) { final JButton option1 = new JButton("option1"); final JButton option2 = new JButton("option2"); option1.setEnabled(false); // option2.setEnabled(false); option1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // pre here } }); option2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // pre here } }); JOptionPane.showOptionDialog(null, "hello", "The Title", JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, new JButton[] { option1, option2 }, option1); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)