JVL Exp8
JVL Exp8
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JDialog.java to edit this
template
*/
package com.mycompany.mygui;
/**
*
* @author apple
*/
public class MHSSCE extends javax.swing.JDialog {
/**
* Creates new form MHSSCE
*/
public MHSSCE(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/**
* 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() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("MHSSCE LOGIN PAGE");
jLabel1.setText("Enter ID");
jLabel2.setText("Password");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jButton1.setText("Login");
jButton2.setText("Cancel");
pack();
}// </editor-fold>
/**
* @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 (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MHSSCE.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MHSSCE.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MHSSCE.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MHSSCE.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
}
//</editor-fold>
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BankAccountApplication extends JFrame implements ActionListener {
private JComboBox<String> accountNumberComboBox;
private JTextField openDateTextField, customerNameTextField, balanceTextField;
private JButton depositButton, withdrawButton, transferButton, exitButton;
public BankAccountApplication() {
// Set up the main frame
setTitle("Bank Account Application");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridBagLayout());
// Create and add components
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5, 5, 5, 5);
// Account Number
gbc.gridx = 0;
gbc.gridy = 0;
add(new JLabel("Account Number:"), gbc);
gbc.gridx = 1;
String[] accountNumbers = {"1231", "1232", "1233"}; // Replace with actual account
numbers
accountNumberComboBox = new JComboBox<>(accountNumbers);
add(accountNumberComboBox, gbc)
// Open Date
gbc.gridx = 0;
gbc.gridy = 1;
add(new JLabel("Open Date:"), gbc);
gbc.gridx = 1;
openDateTextField = new JTextField(20);
add(openDateTextField, gbc);
// Customer Name
gbc.gridx = 0;
gbc.gridy = 2;
add(new JLabel("Customer Name:"), gbc);
gbc.gridx = 1;
customerNameTextField = new JTextField(20);
add(customerNameTextField, gbc);
// Balance
gbc.gridx = 0;
gbc.gridy = 3;
add(new JLabel("Balance:"), gbc);
gbc.gridx = 1;
balanceTextField = new JTextField(20);
balanceTextField.setEditable(false); // Make balance field read-only
add(balanceTextField, gbc);
// Buttons
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 2;
add(depositButton = new JButton("Deposit"), gbc);
gbc.gridy = 5;
add(withdrawButton = new JButton("Withdraw"), gbc);
gbc.gridy = 6;
add(transferButton = new JButton("Transfer To"), gbc);
gbc.gridy = 7;
add(exitButton = new JButton("Exit"), gbc);
// Add event listeners
depositButton.addActionListener(this);
withdrawButton.addActionListener(this);
transferButton.addActionListener(this);
exitButton.addActionListener(this);
// Set frame size and visibility
pack();
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e)
if (e.getSource() == depositButton) {
// Handle deposit action
// ...
} else if (e.getSource() == withdrawButton) {
// Handle withdraw action
// ...
} else if (e.getSource() == transferButton) {
// Handle transfer action
// ...
} else if (e.getSource() == exitButton) {
System.exit(0);
}
}