KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > editor > app > gui > QuestionDialog


1 /*
2  * QuestionDialog.java
3  *
4  * Created on November 15, 2002, 6:48 PM
5  */

6
7 package org.netbeans.test.editor.app.gui;
8
9 /**
10  *
11  * @author eh103527
12  */

13 public class QuestionDialog extends javax.swing.JDialog JavaDoc {
14     
15     boolean answer=false;
16     
17     /** Creates new form QuestionDialog */
18     public QuestionDialog(java.awt.Frame JavaDoc parent, String JavaDoc quest) {
19     super(parent, true);
20     initComponents();
21     textL.setText(quest);
22     pack();
23     setLocation(parent.getX()+(parent.getWidth()-getWidth())/2,parent.getY()+(parent.getHeight()-getHeight())/2);
24     }
25     
26     /** This method is called from within the constructor to
27      * initialize the form.
28      * WARNING: Do NOT modify this code. The content of this method is
29      * always regenerated by the Form Editor.
30      */

31     private void initComponents() {//GEN-BEGIN:initComponents
32
jPanel1 = new javax.swing.JPanel JavaDoc();
33         textL = new javax.swing.JLabel JavaDoc();
34         jPanel2 = new javax.swing.JPanel JavaDoc();
35         yesB = new javax.swing.JButton JavaDoc();
36         noB = new javax.swing.JButton JavaDoc();
37
38         setTitle("Question");
39         setModal(true);
40         setResizable(false);
41         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
42             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
43                 closeDialog(evt);
44             }
45         });
46
47         textL.setFont(new java.awt.Font JavaDoc("Dialog", 1, 14));
48         jPanel1.add(textL);
49
50         getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
51
52         jPanel2.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 10, 10));
53
54         yesB.setText("Yes");
55         yesB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
56             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
57                 yesBActionPerformed(evt);
58             }
59         });
60
61         jPanel2.add(yesB);
62
63         noB.setText("No");
64         noB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
65             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
66                 noBActionPerformed(evt);
67             }
68         });
69
70         jPanel2.add(noB);
71
72         getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
73
74         pack();
75     }//GEN-END:initComponents
76

77     private void noBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_noBActionPerformed
78
// Add your handling code here:
79
answer=false;
80     close();
81     }//GEN-LAST:event_noBActionPerformed
82

83     private void yesBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_yesBActionPerformed
84
// Add your handling code here:
85
answer=true;
86     close();
87     }//GEN-LAST:event_yesBActionPerformed
88

89     /** Closes the dialog */
90     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
91
answer=false;
92     close();
93     }//GEN-LAST:event_closeDialog
94

95     private void close() {
96     setVisible(false);
97     dispose();
98     }
99     /** Getter for property answer.
100      * @return Value of property answer.
101      *
102      */

103     public boolean getAnswer() {
104     return answer;
105     }
106     
107     // Variables declaration - do not modify//GEN-BEGIN:variables
108
private javax.swing.JLabel JavaDoc textL;
109     private javax.swing.JButton JavaDoc noB;
110     private javax.swing.JButton JavaDoc yesB;
111     private javax.swing.JPanel JavaDoc jPanel2;
112     private javax.swing.JPanel JavaDoc jPanel1;
113     // End of variables declaration//GEN-END:variables
114

115 }
116
Popular Tags