summaryrefslogtreecommitdiff
path: root/NET/worlds/console/YesNoCancelDialog.java
blob: 3adbf30595f0d41c291702faaaf900b5a33cefba (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import java.awt.Button;
/*     */ import java.awt.Event;
/*     */ import java.awt.GridBagConstraints;
/*     */ import java.awt.GridBagLayout;
/*     */ import java.awt.Window;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class YesNoCancelDialog
/*     */   extends PolledDialog
/*     */ {
/*     */   private static final long serialVersionUID = 4497394464783317237L;
/*  26 */   private Button yesButton = new Button(Console.message("Yes"));
/*  27 */   private Button noButton = new Button(Console.message("No"));
/*  28 */   private Button cancelButton = new Button(Console.message("Cancel"));
/*  29 */   private GridBagLayout gbag = new GridBagLayout();
/*     */   private String prompt;
/*  31 */   private int choice = -2;
/*     */   
/*     */   public static final int UNDECIDED = -2;
/*     */   public static final int CANCEL = -1;
/*     */   public static final int NO = 0;
/*     */   public static final int YES = 1;
/*     */   
/*     */   public YesNoCancelDialog(Window parent, DialogReceiver receiver, String title, String prompt)
/*     */   {
/*  40 */     super(parent, receiver, title, true);
/*  41 */     this.prompt = prompt;
/*  42 */     setLayout(this.gbag);
/*  43 */     ready();
/*     */   }
/*     */   
/*     */   public int getChoice() {
/*  47 */     return this.choice;
/*     */   }
/*     */   
/*     */   protected void build()
/*     */   {
/*  52 */     GridBagConstraints c = new GridBagConstraints();
/*  53 */     c.weightx = 1.0D;
/*  54 */     c.weighty = 1.0D;
/*  55 */     c.gridwidth = 0;
/*  56 */     add(this.gbag, new MultiLineLabel(this.prompt, 5, 5), c);
/*  57 */     c.gridwidth = 3;
/*  58 */     c.weightx = 1.0D;
/*  59 */     c.weighty = 0.0D;
/*  60 */     add(this.gbag, this.yesButton, c);
/*  61 */     add(this.gbag, this.noButton, c);
/*  62 */     add(this.gbag, this.cancelButton, c);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public void setVisible(boolean visible)
/*     */   {
/*  69 */     super.setVisible(visible);
/*  70 */     if (visible) {
/*  71 */       this.yesButton.requestFocus();
/*     */     }
/*     */   }
/*     */   
/*     */   private boolean yes() {
/*  76 */     this.choice = 1;
/*  77 */     return done(true);
/*     */   }
/*     */   
/*     */   private boolean no() {
/*  81 */     this.choice = 0;
/*  82 */     return done(false);
/*     */   }
/*     */   
/*     */   private boolean cancel() {
/*  86 */     this.choice = -1;
/*  87 */     return done(false);
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean handleEvent(Event event)
/*     */   {
/*  93 */     if (event.id == 201)
/*  94 */       return cancel();
/*  95 */     return super.handleEvent(event);
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean action(Event event, Object what)
/*     */   {
/* 101 */     Object target = event.target;
/* 102 */     if (target == this.yesButton)
/* 103 */       return yes();
/* 104 */     if (target == this.noButton)
/* 105 */       return no();
/* 106 */     if (target == this.cancelButton)
/* 107 */       return cancel();
/* 108 */     return false;
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean keyDown(Event event, int key)
/*     */   {
/* 114 */     if (key == 27)
/* 115 */       return cancel();
/* 116 */     return super.keyDown(event, key);
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\YesNoCancelDialog.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */