ExitFrame.java
Go to the documentation of this file.
1 package p2pgui;
2 
7 public class ExitFrame extends javax.swing.JDialog {
9  public static final int RET_CANCEL = 0;
11  public static final int RET_OK = 1;
12 
18  public ExitFrame(java.awt.Frame parent, boolean modal) {
19  super(parent, modal);
21  }
22 
26  public int getReturnStatus() {
27  return returnStatus;
28  }
29 
34  @SuppressWarnings("unchecked")
35  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
36  private void initComponents() {
37 
38  okButton = new javax.swing.JButton();
39  cancelButton = new javax.swing.JButton();
40  jLabel1 = new javax.swing.JLabel();
41 
42  setTitle("P2PFileSystem - Exit");
43  setFocusCycleRoot(false);
44  setName("ExitFrame"); // NOI18N
45  addWindowListener(new java.awt.event.WindowAdapter() {
46  public void windowClosing(java.awt.event.WindowEvent evt) {
47  closeDialog(evt);
48  }
49  });
50 
51  okButton.setText("SI");
52  okButton.addActionListener(new java.awt.event.ActionListener() {
53  public void actionPerformed(java.awt.event.ActionEvent evt) {
55  }
56  });
57 
58  cancelButton.setText("NO");
59  cancelButton.addActionListener(new java.awt.event.ActionListener() {
60  public void actionPerformed(java.awt.event.ActionEvent evt) {
62  }
63  });
64 
65  jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
66  jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
67  jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Exit.png"))); // NOI18N
68  jLabel1.setText("Vuoi davvero uscire dal programma?");
69 
70  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
71  getContentPane().setLayout(layout);
72  layout.setHorizontalGroup(
73  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74  .addGroup(layout.createSequentialGroup()
75  .addGap(38, 38, 38)
76  .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
77  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE)
78  .addComponent(cancelButton)
79  .addGap(48, 48, 48))
80  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
81  .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
82  .addContainerGap())
83  );
84 
85  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton});
86 
87  layout.setVerticalGroup(
88  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89  .addGroup(layout.createSequentialGroup()
90  .addGap(19, 19, 19)
91  .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
92  .addGap(26, 26, 26)
93  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
94  .addComponent(okButton)
95  .addComponent(cancelButton))
96  .addContainerGap(46, Short.MAX_VALUE))
97  );
98 
99  pack();
100  }// </editor-fold>//GEN-END:initComponents
101 
106  private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
107  //doClose(EXIT_ON_CLOSE);
108  System.exit(0);
109  }//GEN-LAST:event_okButtonActionPerformed
110 
115  private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
117  }//GEN-LAST:event_cancelButtonActionPerformed
118 
123  private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
125  }//GEN-LAST:event_closeDialog
126 
131  private void doClose(int retStatus) {
132  returnStatus = retStatus;
133  setVisible(false);
134  dispose();
135  }
136 
137 
138  // Variables declaration - do not modify//GEN-BEGIN:variables
139  private javax.swing.JButton cancelButton;
140  private javax.swing.JLabel jLabel1;
141  private javax.swing.JButton okButton;
142  // End of variables declaration//GEN-END:variables
143 
144  private int returnStatus = RET_CANCEL;
145 }
static final int RET_OK
Codice di ritorno della stato - ritorna se viene premuto il bottone OK.
Definition: ExitFrame.java:11
ExitFrame(java.awt.Frame parent, boolean modal)
Costruttore che crea un nuovo ExitFrame.
Definition: ExitFrame.java:18
Classe che genera graficamente la finestra di "Exit".
Definition: ExitFrame.java:7
javax.swing.JButton okButton
Definition: ExitFrame.java:141
void cancelButtonActionPerformed(java.awt.event.ActionEvent evt)
Azione da effettuare se avviene la pressione del bottone CANCEL.
Definition: ExitFrame.java:115
javax.swing.JLabel jLabel1
Definition: ExitFrame.java:140
void okButtonActionPerformed(java.awt.event.ActionEvent evt)
Azione da effettuare se avviene la pressione del bottone OK.
Definition: ExitFrame.java:106
void closeDialog(java.awt.event.WindowEvent evt)
Azione da effettuare se avviene la pressione della X per chiudere la finestra.
Definition: ExitFrame.java:123
static final int RET_CANCEL
Codice di ritorno della stato - ritorna se viene premuto il bottone Cancel.
Definition: ExitFrame.java:9
int getReturnStatus()
Funzione che fornisce lo stato di ritorno della finestra.
Definition: ExitFrame.java:26
javax.swing.JButton cancelButton
Definition: ExitFrame.java:139
void initComponents()
Metodo chiamato dal costruttore per inizializzare la form WARNING: Do NOT modify this code...
Definition: ExitFrame.java:36
void doClose(int retStatus)
Funzione imposta lo stato di ritorno in base a retStatus.
Definition: ExitFrame.java:131