import java.awt.event.ActionEvent;
import java.awt.event.ActionListener 입니다.
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class MessageDialog {
public static void main(String[] args) {
JFrame window = new JFrame();
window.setLocationRelativeTo(null);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
JButton leave = new JButton("종료");
window.add(종료);
exit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO 자동 생성 메서드 stub
int return = showConfirmDialog();
if(return==0)//클릭한 버튼이 "yes"인 경우
System.exit(0);
}
});
window.add(종료);
window.pack();
}
static int showConfirmDialog(){
return JOptionPane.showConfirmDialog(
null,
"정말 그만두시겠습니까?",
"종료",
JOptionPane.YES_NO_OPTION);
}
}
Please disable your ad blocker and refresh the window to use this website.