Files
GUIMyBank/src/guimybank/GUIMyBank.java
La Programmatrice Verde f85d8e5749 UX apertura conto corrente
2026-02-17 10:37:48 +01:00

244 lines
12 KiB
Java

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package guimybank;
import java.awt.Color;
import javax.swing.JOptionPane;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
/**
*
* @author Verde
*/
public class GUIMyBank extends javax.swing.JFrame {
private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(GUIMyBank.class.getName());
/**
* Creates new form GUIMyBank
*/
public GUIMyBank() {
initComponents();
btnVersamento.setVisible(false);
btnPrelievo.setVisible(false);
btnListaMovimenti.setVisible(false);
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
lblNome = new javax.swing.JLabel();
lblCognome = new javax.swing.JLabel();
lblCodiceFiscale = new javax.swing.JLabel();
lblDataDiNascita = new javax.swing.JLabel();
lblSaldoIniziale = new javax.swing.JLabel();
txtNome = new javax.swing.JTextField();
txtCognome = new javax.swing.JTextField();
txtCodiceFiscale = new javax.swing.JTextField();
txtDataDiNascita = new javax.swing.JTextField();
txtSaldoIniziale = new javax.swing.JTextField();
btnDataDiNascita = new javax.swing.JButton();
btnAprireContoCorrente = new javax.swing.JButton();
btnVersamento = new javax.swing.JButton();
btnPrelievo = new javax.swing.JButton();
btnListaMovimenti = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
lblNome.setText("Nome");
lblCognome.setText("Cognome");
lblCodiceFiscale.setText("Codice fiscale");
lblDataDiNascita.setText("Data di nascita");
lblSaldoIniziale.setText("Saldo iniziale");
btnDataDiNascita.setText("[]");
btnAprireContoCorrente.setText("Aprire conto corrente");
btnAprireContoCorrente.addActionListener(this::btnAprireContoCorrenteActionPerformed);
btnVersamento.setText("Versamento");
btnPrelievo.setText("Prelievo");
btnListaMovimenti.setText("Lista movimenti");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNome)
.addComponent(lblCognome)
.addComponent(lblCodiceFiscale))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(txtCodiceFiscale, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtCognome, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(txtNome)))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblDataDiNascita)
.addComponent(lblSaldoIniziale))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(txtDataDiNascita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnDataDiNascita, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtSaldoIniziale))))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnVersamento)
.addComponent(btnPrelievo)
.addComponent(btnListaMovimenti))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(99, 99, 99)
.addComponent(btnAprireContoCorrente)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblNome)
.addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblCognome)
.addComponent(txtCognome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnVersamento))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblCodiceFiscale)
.addComponent(txtCodiceFiscale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnPrelievo))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDataDiNascita)
.addComponent(txtDataDiNascita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnDataDiNascita)
.addComponent(btnListaMovimenti))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblSaldoIniziale)
.addComponent(txtSaldoIniziale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(btnAprireContoCorrente)
.addContainerGap(58, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnAprireContoCorrenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAprireContoCorrenteActionPerformed
String nome = txtNome.getText();
String cognome = txtCognome.getText();
String codiceFiscale = txtCodiceFiscale.getText();
String dataDiNascita = txtDataDiNascita.getText();
String saldoIniziale = txtSaldoIniziale.getText();
if(nome.isEmpty()){
JOptionPane.showMessageDialog(null, "Inserire il proprio nome.");
txtNome.setBorder(new LineBorder(Color.red));
return;
}
if(cognome.isEmpty()){
JOptionPane.showMessageDialog(null, "Inserire il proprio cognome.");
txtCognome.setBorder(new LineBorder(Color.red));
return;
}
//TODO: verifica codice fiscale
if(codiceFiscale.isEmpty()){
JOptionPane.showMessageDialog(null, "Inserire il proprio codice fiscale.");
txtCodiceFiscale.setBorder(new LineBorder(Color.red));
return;
}
//TODO: gestione data
//if(dataDiNascita.isEmpty()){
// JOptionPane.showMessageDialog(null, "Inserire la propria data di nascita.");
// txtDataDiNascita.setBorder(new LineBorder(Color.red));
// return;
//}
if(saldoIniziale.isEmpty()){
JOptionPane.showMessageDialog(null, "Inserire il proprio saldo iniziale.");
txtSaldoIniziale.setBorder(new LineBorder(Color.red));
return;
}
btnVersamento.setVisible(true);
btnPrelievo.setVisible(true);
btnListaMovimenti.setVisible(true);
txtNome.setEditable(false);
txtCognome.setEditable(false);
txtCodiceFiscale.setEditable(false);
txtDataDiNascita.setEditable(false);
txtSaldoIniziale.setEditable(false);
}//GEN-LAST:event_btnAprireContoCorrenteActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ReflectiveOperationException | javax.swing.UnsupportedLookAndFeelException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> new GUIMyBank().setVisible(true));
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAprireContoCorrente;
private javax.swing.JButton btnDataDiNascita;
private javax.swing.JButton btnListaMovimenti;
private javax.swing.JButton btnPrelievo;
private javax.swing.JButton btnVersamento;
private javax.swing.JLabel lblCodiceFiscale;
private javax.swing.JLabel lblCognome;
private javax.swing.JLabel lblDataDiNascita;
private javax.swing.JLabel lblNome;
private javax.swing.JLabel lblSaldoIniziale;
private javax.swing.JTextField txtCodiceFiscale;
private javax.swing.JTextField txtCognome;
private javax.swing.JTextField txtDataDiNascita;
private javax.swing.JTextField txtNome;
private javax.swing.JTextField txtSaldoIniziale;
// End of variables declaration//GEN-END:variables
}