0% found this document useful (0 votes)
4 views

depositjava project

Uploaded by

abhi9410799101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

depositjava project

Uploaded by

abhi9410799101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package bank.

management;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

public class Deposit extends JFrame implements ActionListener {


String pin;
JTextField textfield;
JButton b1, b2;

Deposit(String pin) {
this.pin = pin;

// Load background image


ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/atm2.png"));
Image i2 = i1.getImage().getScaledInstance(1550, 830, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
image.setBounds(0, 0, 1550, 830);
add(image);

// Label for the amount input field


JLabel l1 = new JLabel("ENTER THE AMOUNT YOU WANT TO DEPOSIT");
l1.setForeground(Color.WHITE);
l1.setFont(new Font("Raleway", Font.BOLD, 16));
l1.setBounds(460, 180, 400, 35);
image.add(l1);

// Amount input field


textfield = new JTextField();
textfield.setBackground(new Color(65, 125, 128));
textfield.setForeground(Color.WHITE);
textfield.setBounds(460, 230, 320, 25);
textfield.setFont(new Font("Raleway", Font.BOLD, 22));
image.add(textfield);

// Deposit button
b1 = new JButton("DEPOSIT");
b1.setBounds(700, 362, 150, 35);
b1.setBackground(new Color(65, 125, 128));
b1.setForeground(Color.WHITE);
b1.addActionListener(this);
image.add(b1);

// Back button
b2 = new JButton("BACK");
b2.setBounds(700, 406, 150, 35);
b2.setBackground(new Color(65, 125, 128));
b2.setForeground(Color.WHITE);
b2.addActionListener(this);
image.add(b2);

setLayout(null);
setSize(1550, 1080);
setLocation(0, 0);
setVisible(true);
}

@Override
public void actionPerformed(ActionEvent e) {
try {
String amount = textfield.getText();
Date date = new Date();
if (e.getSource() == b1) {
if (textfield.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Please enter the amount you want to
deposit");
} else {
Con c = new Con();
// Fixed SQL syntax error: Corrected the query string
String query = "INSERT INTO bank (pin, date, type, amount) VALUES ('" + pin + "',
'" + date + "', 'Deposit', '" + amount + "')";
c.stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Rs. " + amount + " deposited
successfully");
setVisible(false);
}
} else if (e.getSource() == b2) {
setVisible(false);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}

public static void main(String[] args) {


new Deposit("");
}
}

You might also like