001: /*
002: * QuestionDialog.java
003: *
004: * Created on November 15, 2002, 6:48 PM
005: */
006:
007: package org.netbeans.test.editor.app.gui;
008:
009: /**
010: *
011: * @author eh103527
012: */
013: public class QuestionDialog extends javax.swing.JDialog {
014:
015: boolean answer = false;
016:
017: /** Creates new form QuestionDialog */
018: public QuestionDialog(java.awt.Frame parent, String quest) {
019: super (parent, true);
020: initComponents();
021: textL.setText(quest);
022: pack();
023: setLocation(parent.getX() + (parent.getWidth() - getWidth())
024: / 2, parent.getY() + (parent.getHeight() - getHeight())
025: / 2);
026: }
027:
028: /** This method is called from within the constructor to
029: * initialize the form.
030: * WARNING: Do NOT modify this code. The content of this method is
031: * always regenerated by the Form Editor.
032: */
033: private void initComponents() {//GEN-BEGIN:initComponents
034: jPanel1 = new javax.swing.JPanel();
035: textL = new javax.swing.JLabel();
036: jPanel2 = new javax.swing.JPanel();
037: yesB = new javax.swing.JButton();
038: noB = new javax.swing.JButton();
039:
040: setTitle("Question");
041: setModal(true);
042: setResizable(false);
043: addWindowListener(new java.awt.event.WindowAdapter() {
044: public void windowClosing(java.awt.event.WindowEvent evt) {
045: closeDialog(evt);
046: }
047: });
048:
049: textL.setFont(new java.awt.Font("Dialog", 1, 14));
050: jPanel1.add(textL);
051:
052: getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
053:
054: jPanel2.setLayout(new java.awt.FlowLayout(
055: java.awt.FlowLayout.CENTER, 10, 10));
056:
057: yesB.setText("Yes");
058: yesB.addActionListener(new java.awt.event.ActionListener() {
059: public void actionPerformed(java.awt.event.ActionEvent evt) {
060: yesBActionPerformed(evt);
061: }
062: });
063:
064: jPanel2.add(yesB);
065:
066: noB.setText("No");
067: noB.addActionListener(new java.awt.event.ActionListener() {
068: public void actionPerformed(java.awt.event.ActionEvent evt) {
069: noBActionPerformed(evt);
070: }
071: });
072:
073: jPanel2.add(noB);
074:
075: getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
076:
077: pack();
078: }//GEN-END:initComponents
079:
080: private void noBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noBActionPerformed
081: // Add your handling code here:
082: answer = false;
083: close();
084: }//GEN-LAST:event_noBActionPerformed
085:
086: private void yesBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yesBActionPerformed
087: // Add your handling code here:
088: answer = true;
089: close();
090: }//GEN-LAST:event_yesBActionPerformed
091:
092: /** Closes the dialog */
093: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
094: answer = false;
095: close();
096: }//GEN-LAST:event_closeDialog
097:
098: private void close() {
099: setVisible(false);
100: dispose();
101: }
102:
103: /** Getter for property answer.
104: * @return Value of property answer.
105: *
106: */
107: public boolean getAnswer() {
108: return answer;
109: }
110:
111: // Variables declaration - do not modify//GEN-BEGIN:variables
112: private javax.swing.JLabel textL;
113: private javax.swing.JButton noB;
114: private javax.swing.JButton yesB;
115: private javax.swing.JPanel jPanel2;
116: private javax.swing.JPanel jPanel1;
117: // End of variables declaration//GEN-END:variables
118:
119: }
|