1 6 7 package org.netbeans.test.editor.app.gui; 8 9 13 public class QuestionDialog extends javax.swing.JDialog { 14 15 boolean answer=false; 16 17 18 public QuestionDialog(java.awt.Frame parent, String 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 31 private void initComponents() { jPanel1 = new javax.swing.JPanel (); 33 textL = new javax.swing.JLabel (); 34 jPanel2 = new javax.swing.JPanel (); 35 yesB = new javax.swing.JButton (); 36 noB = new javax.swing.JButton (); 37 38 setTitle("Question"); 39 setModal(true); 40 setResizable(false); 41 addWindowListener(new java.awt.event.WindowAdapter () { 42 public void windowClosing(java.awt.event.WindowEvent evt) { 43 closeDialog(evt); 44 } 45 }); 46 47 textL.setFont(new java.awt.Font ("Dialog", 1, 14)); 48 jPanel1.add(textL); 49 50 getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); 51 52 jPanel2.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.CENTER, 10, 10)); 53 54 yesB.setText("Yes"); 55 yesB.addActionListener(new java.awt.event.ActionListener () { 56 public void actionPerformed(java.awt.event.ActionEvent evt) { 57 yesBActionPerformed(evt); 58 } 59 }); 60 61 jPanel2.add(yesB); 62 63 noB.setText("No"); 64 noB.addActionListener(new java.awt.event.ActionListener () { 65 public void actionPerformed(java.awt.event.ActionEvent evt) { 66 noBActionPerformed(evt); 67 } 68 }); 69 70 jPanel2.add(noB); 71 72 getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); 73 74 pack(); 75 } 77 private void noBActionPerformed(java.awt.event.ActionEvent evt) { answer=false; 80 close(); 81 } 83 private void yesBActionPerformed(java.awt.event.ActionEvent evt) { answer=true; 86 close(); 87 } 89 90 private void closeDialog(java.awt.event.WindowEvent evt) { answer=false; 92 close(); 93 } 95 private void close() { 96 setVisible(false); 97 dispose(); 98 } 99 103 public boolean getAnswer() { 104 return answer; 105 } 106 107 private javax.swing.JLabel textL; 109 private javax.swing.JButton noB; 110 private javax.swing.JButton yesB; 111 private javax.swing.JPanel jPanel2; 112 private javax.swing.JPanel jPanel1; 113 115 } 116 | Popular Tags |