티스토리 뷰
출처 : http://www.java-forums.org/java-tips/6578-messagebox-example.html
public class MessageBox {
/*
These are a list of STATIC MODAL dialogs
int return codes of button pressed:
-1 - WINDOW CLOSED - the X PRESSED
0 - YES and OK
1 - NO
2 - CANCEL
(thanks to flipside for the idea)
*/
public static int yesno(String theMessage){
int result = JOptionPane.showConfirmDialog((Component)
null, theMessage, "alert", JOptionPane.YES_NO_OPTION);
return result;
}
public static int yesnocancel(String theMessage){
int result = JOptionPane.showConfirmDialog((Component)
null, theMessage, "alert", JOptionPane.YES_NO_CANCEL_OPTION);
return result;
}
public static int okcancel(String theMessage){
int result = JOptionPane.showConfirmDialog((Component)
null, theMessage, "alert", JOptionPane.OK_CANCEL_OPTION);
return result;
}
public static int ok(String theMessage){
int result = JOptionPane.showConfirmDialog((Component)
null, theMessage, "alert", JOptionPane.DEFAULT_OPTION);
return result;
}
public static void main(String args[]){
int i = MessageBox.yesno("Are your sure ?");
System.out.println("ret : " + i );
i = MessageBox.yesnocancel("Are your sure ?");
System.out.println("ret : " + i );
i = MessageBox.okcancel("Are your sure ?");
System.out.println("ret : " + i );
i = MessageBox.ok("Done.");
System.out.println("ret : " + i );
}
}
'Studying > JAVA' 카테고리의 다른 글
클래스 설계 기법 (0) | 2011.03.28 |
---|---|
BlueCove stack (0) | 2011.03.28 |
외부 라이브러리를 포함한 Jar 파일 만들기 (0) | 2011.03.28 |
Singleton (싱글톤) 패턴 (0) | 2011.03.24 |
현재 마우스 포인트 위치 구하기 (0) | 2011.03.24 |