Rights.java
Go to the documentation of this file.
1 package p2pgui;
2 
8 public class Rights extends javax.swing.JDialog {
10  public static final int RET_CANCEL = 0;
12  public static final int RET_OK = 1;
13 
14  public static boolean read;
15  public static boolean write;
16 
22  public Rights(java.awt.Frame parent, boolean modal) {
23  super(parent, modal);
25  }
26 
30  public int getReturnStatus() {
31  return returnStatus;
32  }
33 
34  /*Metodo chiamato dal costruttore per inizializzare la form
35  * WARNING: Do NOT modify this code. The content of this method is
36  * always regenerated by the Form Editor.
37  */
38  @SuppressWarnings("unchecked")
39  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
40  private void initComponents() {
41 
42  okButton = new javax.swing.JButton();
43  jLabel1 = new javax.swing.JLabel();
44  jCheckBox1 = new javax.swing.JCheckBox();
45  jCheckBox2 = new javax.swing.JCheckBox();
46 
47  setTitle("P2PFileSystem - Rights");
48  setLocationByPlatform(true);
49  addWindowListener(new java.awt.event.WindowAdapter() {
50  public void windowClosing(java.awt.event.WindowEvent evt) {
51  closeDialog(evt);
52  }
53  });
54 
55  okButton.setText("OK");
56  okButton.addActionListener(new java.awt.event.ActionListener() {
57  public void actionPerformed(java.awt.event.ActionEvent evt) {
59  }
60  });
61 
62  jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
63  jLabel1.setText("Select rights:");
64 
65  jCheckBox1.setSelected(true);
66  jCheckBox1.setText("Read");
67  jCheckBox1.setEnabled(false);
68 
69  jCheckBox2.setText("Write");
70 
71  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
72  getContentPane().setLayout(layout);
73  layout.setHorizontalGroup(
74  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
75  .addGroup(layout.createSequentialGroup()
76  .addGap(41, 41, 41)
77  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78  .addGroup(layout.createSequentialGroup()
79  .addGap(33, 33, 33)
80  .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
81  .addGroup(layout.createSequentialGroup()
82  .addComponent(jCheckBox1)
83  .addGap(30, 30, 30)
84  .addComponent(jCheckBox2)))
85  .addContainerGap(41, Short.MAX_VALUE))
86  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
87  .addContainerGap(65, Short.MAX_VALUE)
88  .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
89  .addGap(29, 29, 29))
90  );
91  layout.setVerticalGroup(
92  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
94  .addContainerGap(15, Short.MAX_VALUE)
95  .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
96  .addGap(18, 18, 18)
97  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
98  .addComponent(jCheckBox1)
99  .addComponent(jCheckBox2))
100  .addGap(25, 25, 25)
101  .addComponent(okButton)
102  .addContainerGap())
103  );
104 
105  pack();
106  }// </editor-fold>//GEN-END:initComponents
111  private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
112  doClose(RET_OK);
113  read = jCheckBox1.isSelected();
114  write = jCheckBox2.isSelected();
115 
116  }//GEN-LAST:event_okButtonActionPerformed
117 
122  private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
124  read = true;
125  write = false;
126  }//GEN-LAST:event_closeDialog
127 
132  private void doClose(int retStatus) {
133  returnStatus = retStatus;
134  setVisible(false);
135  dispose();
136  }
137 
138  // Variables declaration - do not modify//GEN-BEGIN:variables
139  private javax.swing.JCheckBox jCheckBox1;
140  private javax.swing.JCheckBox jCheckBox2;
141  private javax.swing.JLabel jLabel1;
142  private javax.swing.JButton okButton;
143  // End of variables declaration//GEN-END:variables
144 
145  private int returnStatus = RET_CANCEL;
146 }
static boolean read
Definition: Rights.java:14
javax.swing.JLabel jLabel1
Definition: Rights.java:141
static final int RET_CANCEL
Codice di ritorno della stato - ritorna se viene premuto il bottone Cancel.
Definition: Rights.java:10
static final int RET_OK
Codice di ritorno della stato - ritorna se viene premuto il bottone OK.
Definition: Rights.java:12
void doClose(int retStatus)
Funzione imposta lo stato di ritorno in base a retStatus.
Definition: Rights.java:132
static boolean write
Definition: Rights.java:15
void initComponents()
Definition: Rights.java:40
Classe che genera graficamente la finestra Rights che richiede di selezionare i permessi d&#39;accesso al...
Definition: Rights.java:8
void okButtonActionPerformed(java.awt.event.ActionEvent evt)
Azione da effettuare se avviene la pressione del bottone OK.
Definition: Rights.java:111
javax.swing.JCheckBox jCheckBox1
Definition: Rights.java:139
javax.swing.JCheckBox jCheckBox2
Definition: Rights.java:140
Rights(java.awt.Frame parent, boolean modal)
Costruttore che crea un nuovo Rights.
Definition: Rights.java:22
javax.swing.JButton okButton
Definition: Rights.java:142
void closeDialog(java.awt.event.WindowEvent evt)
Azione da effettuare se avviene la pressione della X per chiudere la finestra.
Definition: Rights.java:122
int returnStatus
Definition: Rights.java:145
int getReturnStatus()
Funzione che fornisce lo stato di ritorno della finestra.
Definition: Rights.java:30