Before creating OptionPane we need to understand What is OptionPane in Java.
OPTION PANE IN JAVA:
In this tutorial i have created option pane of question type therefore it has question icon.
CODING:
import javax.swing.*;import java.awt.*;
class myjframe1 extends JFrame
{
public myjframe1() {
JOptionPane jp = new JOptionPane();
Object[] options = { "YES", "NO" };
JDialog.setDefaultLookAndFeelDecorated(true);
int button = jp.showOptionDialog(null,
" DO YOU WANT TO EXIT " , "Exit Confirmation",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,
null, options, options[1]);
if (button == 0) {A
System.exit(0) ;}
}
}
class exit
{
public static void main(String args[])
{
myjframe1 x= new myjframe1();
}
}
No comments:
Post a Comment