ragazzi io voglio che mi faccia apparire una finestra dove devo inserire il numero delle persone e poi
con quel numero il programma funziona ma io non so come fare.Non ho inserito tutto il codice perchè non me lo faceva inserire.
codice:
import javax.swing.JOptionPane;
import javax.swing.table.TableModel;
import java.util.Vector;
import javax.swing.event.TableModelListener;
import javax.swing.text.TableView;
import javax.swing.table.DefaultTableModel;
public class EseMaschera extends javax.swing.JFrame {
static record[] record =new record[2];
public EseMaschera() {
initComponents();
for(int i=0;i<2;i++) {
record[i]=new record();
}
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
LblNome = new javax.swing.JLabel();
LblCognome = new javax.swing.JLabel();
LblCodFiscale = new javax.swing.JLabel();
LblClasse = new javax.swing.JLabel();
LblIndirizzo = new javax.swing.JLabel();
LblResidenza = new javax.swing.JLabel();
LblDatadiNascita = new javax.swing.JLabel();
LblTelefono = new javax.swing.JLabel();
TxtNome = new javax.swing.JTextField();
TxtCognome = new javax.swing.JTextField();
TxtCodFiscale = new javax.swing.JTextField();
CmbClasse = new javax.swing.JComboBox();
TxtIndirizzo = new javax.swing.JTextField();
TxtResidenza = new javax.swing.JTextField();
TxtTelefono = new javax.swing.JTextField();
TxtDataGiorno = new javax.swing.JTextField();
BtnReset = new javax.swing.JButton();
BtnInvia = new javax.swing.JButton();
TxtDataMese = new javax.swing.JTextField();
TxtDataAnno = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
LblNome.setText(" Nome:");
LblCognome.setText(" Cognome:");
LblCodFiscale.setText(" CodFiscale:");
LblClasse.setText(" Classe:");
LblIndirizzo.setText(" Indirizzo:");
LblResidenza.setText(" Residenza:");
LblDatadiNascita.setText(" Data di nascita: ");
LblTelefono.setText(" Telefono:");
TxtNome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtNomeActionPerformed(evt);
}
});
TxtNome.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtNomeKeyTyped(evt);
}
});
TxtCognome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtCognomeActionPerformed(evt);
}
});
TxtCognome.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtCognomeKeyTyped(evt);
}
});
TxtCodFiscale.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtCodFiscaleActionPerformed(evt);
}
});
TxtCodFiscale.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtCodFiscaleKeyTyped(evt);
}
});
CmbClasse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "1Ai", "2Ai", "3Ai", "4Ai", "5Ai" }));
CmbClasse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmbClasseActionPerformed(evt);
}
});
TxtIndirizzo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtIndirizzoActionPerformed(evt);
}
});
TxtIndirizzo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtIndirizzoKeyTyped(evt);
}
});
TxtResidenza.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtResidenzaActionPerformed(evt);
}
});
TxtResidenza.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtResidenzaKeyTyped(evt);
}
});
TxtTelefono.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtTelefonoActionPerformed(evt);
}
});
TxtTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtTelefonoKeyTyped(evt);
}
});
TxtDataGiorno.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtDataGiornoActionPerformed(evt);
}
});
TxtDataGiorno.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtDataGiornoKeyTyped(evt);
}
});
BtnReset.setText("Reset");
BtnReset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BtnResetActionPerformed(evt);
}
});
BtnInvia.setText("Invia");
BtnInvia.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BtnInviaActionPerformed(evt);
}
});
TxtDataMese.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtDataMeseActionPerformed(evt);
}
});
TxtDataMese.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtDataMeseKeyTyped(evt);
}
});
TxtDataAnno.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TxtDataAnnoActionPerformed(evt);
}
});
TxtDataAnno.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
TxtDataAnnoKeyTyped(evt);
}
});
jLabel1.setText(" /");
jLabel2.setText(" /");
private void TxtResidenzaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void TxtTelefonoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void TxtDataGiornoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void BtnResetActionPerformed(java.awt.event.ActionEvent evt) {
TxtNome.setText(null);
TxtCognome.setText(null);
TxtCodFiscale.setText(null);
CmbClasse.setSelectedIndex(0);
TxtIndirizzo.setText(null);
TxtResidenza.setText(null);
TxtDataGiorno.setText(null);
TxtDataMese.setText(null);
TxtDataAnno.setText(null);
TxtTelefono.setText(null);
}
static int i=0;
private void BtnInviaActionPerformed(java.awt.event.ActionEvent evt) {
record[i].Nome=TxtNome.getText();
record[i].Cognome=TxtCognome.getText();
record[i].CodFiscale=TxtCodFiscale.getText();
record[i].jComboBox=(String) CmbClasse.getSelectedItem();
record[i].Indirizzo=TxtIndirizzo.getText();
record[i].Residenza=TxtResidenza.getText();
record[i].DataGiorno=TxtDataGiorno.getText();
record[i].DataMese=TxtDataMese.getText();
record[i].DataAnno=TxtDataAnno.getText();
record[i].Telefono=TxtTelefono.getText();
JOptionPane.showMessageDialog(null,"Nome: " + record[i].Nome +"\n"+"Cognome: " + record[i].Cognome+"\n"+"Cod.Fiscale: " +record[i].CodFiscale+"\n"+"Classe: " +record[i].jComboBox+"\n"+"Indirizzo: " + record[i].Indirizzo+"\n"+"Residenza: " +record[i].Residenza+"\n"+"Data di Nascita: " +record[i].DataGiorno+"/"+record[i].DataMese+"/"+record[i].DataAnno+"\n"+"Telefono: "+ record[i].Telefono);
TxtNome.setText(null);
TxtCognome.setText(null);
TxtCodFiscale.setText(null);
CmbClasse.setSelectedIndex(0);
TxtIndirizzo.setText(null);
TxtResidenza.setText(null);
TxtDataGiorno.setText(null);
TxtDataMese.setText(null);
TxtDataAnno.setText(null);
TxtTelefono.setText(null);
i++;
}
private void TxtDataAnnoKeyTyped(java.awt.event.KeyEvent evt) {
int numerocaratteri=4;
if(TxtDataAnno.getText().length()>=numerocaratteri){
evt.consume();
JOptionPane.showMessageDialog(rootPane,"Sono più di 4 caratteri");
}
}
private void TxtTelefonoKeyTyped(java.awt.event.KeyEvent evt) {
int numerocaratteri=10;
if(TxtTelefono.getText().length()>=numerocaratteri){
evt.consume();
JOptionPane.showMessageDialog(rootPane,"Sono più di 10 caratteri");
}
}