본문 바로가기

카테고리 없음

Dialog

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package swing;
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
 
public class DialogExam2 extends JFrame {
 
    public DialogExam2() {
        int res = JOptionPane.showOptionDialog(
                null, 
                "원하는 작업 선택해", 
                "대화상자", 
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.INFORMATION_MESSAGE, 
                null, 
                new String[] { "가입하기", "다시쓰기", "취소" }, "가입하기");
 
        System.out.println(res);
    }
 
    public void test2() {
        int result = JOptionPane.showConfirmDialog(this, "작업을 종료하실라우?"); //1
        System.out.println(result); //2
        if (result == 0) { //3
            System.out.println("예를 선택 했씁니다");
        } else if (result == 1) {
            System.out.println("아니오를 선택 했씁니다");
        } else if (result == 2) {
            System.out.println("취소를 선택 했씁니다");
        }
    }
 
    public void test() {
        // JOptionPane.showMessageDialog(null, "일자리가 보장 됨"); // 1)
        String inputMsg = JOptionPane.showInputDialog("아이디 입력 :"); // 2
        // System.out.println(inputMsg);//3
 
        JOptionPane.showMessageDialog(this, inputMsg + "님의 일자리가 보장 됨"); //3}
    }
 
    public static void main(String[] args) {
        new DialogExam2();
    }
}
 
cs