Tips for heathy life

Tips for heathy life

Kamis, 30 Oktober 2008

Make DIALOG in Java SE 2



I want to share how to Make DIALOG in Java 2 SE. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Main {


public Main() {
}


public static void main(String[] args) {

JFrame frame =new JFrame("Interface Frame in Java");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();

int result=JOptionPane.showConfirmDialog(frame,"Choose OK or Cancel?","Title of confirmation",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
String message;
if(result==JOptionPane.OK_OPTION)
message="You choose OK";
else if (result==JOptionPane.CANCEL_OPTION)
message="You choose CANCEL";
else
message="You didnt choose anything";
JOptionPane.showMessageDialog(frame,message,"Your choice",JOptionPane.INFORMATION_MESSAGE);
}
}

0 komentar:

Posting Komentar