import javax.swing.*;
import java.awt.event.*;public class AA extends JFrame {
Container c;
int value; public AA() {
super("aa");
setSize(300, 200);
c = getContentPane();
c.setLayout(new BorderLayout()); JButton b = new JButton("a");
ActionListener action = new ActionListener() {
public void actionPerformed(ActionEvent e) { value =JOptionPane.showConfirmDialog(c,"要继续吗","提示信息",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE );
if (value ==JOptionPane.OK_OPTION){
JOptionPane.showMessageDialog(c,"message1","message1",JOptionPane.YES_OPTION);
}
if(value ==JOptionPane.CANCEL_OPTION){
JOptionPane.showMessageDialog(c,"message2","message2",JOptionPane.YES_OPTION);
}
}
};
b.addActionListener(action);
c.add(b, BorderLayout.CENTER);
setVisible(true);
} public static void main(String args[]) {
AA a = new AA();
}
}
import java.awt.event.*;public class AA extends JFrame {
Container c;
int value; public AA() {
super("aa");
setSize(300, 200);
c = getContentPane();
c.setLayout(new BorderLayout()); JButton b = new JButton("a");
ActionListener action = new ActionListener() {
public void actionPerformed(ActionEvent e) { value =JOptionPane.showConfirmDialog(c,"要继续吗","提示信息",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE );
if (value ==JOptionPane.OK_OPTION){
JOptionPane.showMessageDialog(c,"message1","message1",JOptionPane.YES_OPTION);
}
if(value ==JOptionPane.CANCEL_OPTION){
JOptionPane.showMessageDialog(c,"message2","message2",JOptionPane.YES_OPTION);
}
}
};
b.addActionListener(action);
c.add(b, BorderLayout.CENTER);
setVisible(true);
} public static void main(String args[]) {
AA a = new AA();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货