esempio di una mia classe
package amministrazione;
import java.util.Vector;
/**
*
* @author gio
*/
public class Dati_Personali extends javax.swing.JFrame {
private static String Utente = "";
private static String Tipo = "";
private static int Codice;
/** Creates new form Dati_Personali */
public Dati_Personali() {
initComponents();
//recupero i dati dal server e li stampo
try { // Call Web Service Operation
scriptorium.ServerService service = new scriptorium.ServerService();
scriptorium.Server port = service.getServerPort();
// TODO initialize WS operation arguments here
java.lang.String arg0 = String.valueOf(Codice);
// TODO process result here
java.util.List<java.lang.Object> result = port.recuperaDatiPersone(arg0);
//salvo i valori ricevuti
//stampo sul form i valori ricevuti
txtCodice.setText(String.valueOf(Codice));
txtCognome.setText((String) result.get(0));
txtNome.setText((String) result.get(1));
txtCF.setText((String) result.get(2));
txtIndirizzo.setText((String) result.get(3));
txtMail.setText((String) result.get(4));
txtTel.setText((String) result.get(5));
txtCellulare.setText((String) result.get(6));
} catch (Exception ex) {
// TODO handle custom exceptions here
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
txtCodice = new javax.swing.JTextField();
txtCognome = new javax.swing.JTextField();
txtNome = new javax.swing.JTextField();
txtCF = new javax.swing.JTextField();
txtMail = new javax.swing.JTextField();
txtTel = new javax.swing.JTextField();
cmdChiudi = new javax.swing.JButton();
cmdSalva = new javax.swing.JButton();
labelRisposta = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
txtIndirizzo = new javax.swing.JTextField();
txtCellulare = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
txtRuolo = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Nome");
jLabel2.setText("Cognome");
jLabel3.setText("Codice Personale");
jLabel4.setText("Codice Fiscale");
jLabel5.setText("Email");
jLabel6.setText("Telefono d'ufficio");
txtCodice.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtCodiceActionPerformed(evt);
}
});
cmdChiudi.setText("Chiudi");
cmdChiudi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdChiudiActionPerformed(evt);
}
});
cmdSalva.setText("Salva le modifiche");
cmdSalva.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdSalvaActionPerformed(evt);
}
});
labelRisposta.setText("Risposta");
jLabel7.setText("SCHEDA RIASSUNTIVA DATI PERSONALI");
jLabel8.setText("Cellulare");
jLabel9.setText("Indirizzo");
jLabel10.setText("Ruolo");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel9))
.addGap(24, 24, 24))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtIndirizzo, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.addComponent(txtCellulare, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.addComponent(txtRuolo, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.addComponent(txtTel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtMail)
.addComponent(txtCF, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtNome, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtCodice, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtCognome, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(122, 122, 122))
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 279, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(203, 203, 203))
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cmdSalva)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdChiudi))
.addComponent(labelRisposta, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(373, 373, 373))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel7)
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtCodice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtCognome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtCF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6))
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(txtMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtIndirizzo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtCellulare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(jLabel9)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(txtRuolo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelRisposta)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdSalva)
.addComponent(cmdChiudi))
.addContainerGap(39, Short.MAX_VALUE))
);
txtCodice.setEditable(false);
labelRisposta.setVisible(false);
txtRuolo.setEditable(false);
pack();
}// </editor-fold>
private void txtCodiceActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cmdChiudiActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
}
private void cmdSalvaActionPerformed(java.awt.event.ActionEvent evt) {
try { // Call Web Service Operation
scriptorium.ServerService service = new scriptorium.ServerService();
scriptorium.Server port = service.getServerPort();
// TODO initialize WS operation arguments here
Vector vet = new Vector();
vet.add(0, txtCodice.getText());
vet.add(1, txtNome.getText());
vet.add(2, txtCognome.getText());
vet.add(3, txtCF.getText());
vet.add(4, txtIndirizzo.getText());
vet.add(5, txtMail.getText());
vet.add(6, txtTel.getText());
vet.add(7, txtCellulare.getText());
System.out.println(vet);
// TODO process result here
boolean result = port.salvaModificheDati(vet);
if(result=true){
labelRisposta.setText("Modifica effettuata \ncon successo");
labelRisposta.setVisible(true);
}else{
labelRisposta.setText("Modifica non riuscita");
labelRisposta.setVisible(true);
}
} catch (Exception ex) {
// TODO handle custom exceptions here
System.out.println("Errore");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
Utente = args[0];
Codice = Integer.parseInt(args[1]);
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Dati_Personali().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton cmdChiudi;
private javax.swing.JButton cmdSalva;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel labelRisposta;
private javax.swing.JTextField txtCF;
private javax.swing.JTextField txtCellulare;
private javax.swing.JTextField txtCodice;
private javax.swing.JTextField txtCognome;
private javax.swing.JTextField txtIndirizzo;
private javax.swing.JTextField txtMail;
private javax.swing.JTextField txtNome;
private javax.swing.JTextField txtRuolo;
private javax.swing.JTextField txtTel;
// End of variables declaration
}
vorrei poter modificare questa classe perchè, al click del menu "dati personali" venga aperta questa classe all'interno dello stesso frame del menu!
è fattibile? hai suggerimenti su come posso procedere?