Final Code
Final Code
import java.sql.*;
import java.time.LocalDate;
import java.time.Period;
import java.time.Year;
import java.util.HashMap;
import java.util.Map;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
ResultSet rs = null;
SwingUtilities.invokeLater(() -> {
app.createAndShowGUI();
});
loginFrame = createLoginFrame(null);
loginFrame.setVisible(true);
f.getContentPane().setBackground(Color.BLACK);
f.setSize(540, 466);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
f.getContentPane().add(lblSelectUserType);
f.getContentPane().add(comboBox);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(btnSignUp);
btnSignUp.addActionListener(new ActionListener() {
createRegisterframe(username);
f.dispose();
});
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(frontLabel);
JLabel frontLabel1 = new JLabel("");
frontLabel1.setIcon(new ImageIcon(frontImage1));
f.getContentPane().add(frontLabel1);
f.getContentPane().add(usernameLabel);
f.getContentPane().add(usernameField);
f.getContentPane().add(passwordLabel);
f.getContentPane().add(passwordField);
JCheckBox showPassword = new JCheckBox("Show Password");
showPassword.setForeground(Color.WHITE);
f.getContentPane().add(showPassword);
showPassword.addActionListener(new ActionListener() {
if (showPassword.isSelected()) {
passwordField.setEchoChar((char) 0);
} else {
passwordField.setEchoChar('*');
});
f.getContentPane().add(loginButton);
loginButton.addActionListener(new ActionListener() {
});
f.getContentPane().add(cancelButton);
JLabel label = new JLabel("");
label.setIcon(new ImageIcon(img));
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(700, 710);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
lblNewLabel_2_3_2_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_2_1);
JTextField userr = new JTextField();
userr.setHorizontalAlignment(SwingConstants.CENTER);
f.getContentPane().add(userr);
lblNewLabel_2_1_1_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_1_1_1);
lblNewLabel_2_1_1_1_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_1_1_1_1);
f.getContentPane().add(passwo);
emailact.setHorizontalAlignment(SwingConstants.CENTER);
f.getContentPane().add(emailact);
lblNewLabel_2_3_3.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_3);
f.getContentPane().add(cancelButton);
lblNewLabel_1.setHorizontalAlignment(SwingConstants.LEFT);
f.getContentPane().add(lblNewLabel_1);
fnameact.setHorizontalAlignment(SwingConstants.CENTER);
f.getContentPane().add(fnameact);
mnameact.setHorizontalAlignment(SwingConstants.CENTER);
f.getContentPane().add(mnameact);
lnameact.setHorizontalAlignment(SwingConstants.CENTER);
f.getContentPane().add(lnameact);
btnSignIn.addActionListener(new ActionListener() {
loginFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnSignIn);
f.getContentPane().add(lblNewLabel);
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3.setBounds(51, 124, 572, 131);
f.getContentPane().add(lblNewLabel_3);
lblNewLabel_2_3.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3);
lblNewLabel_2_3_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1);
lblNewLabel_2_3_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_2);
f.getContentPane().add(birthdateLabel);
f.getContentPane().add(birthdateDayDropdown);
f.getContentPane().add(birthdateMonthDropdown);
f.getContentPane().add(birthdateYearDropdown);
f.getContentPane().add(ageField);
@Override
ageField.setText(Integer.toString(age));
};
birthdateDayDropdown.addActionListener(birthdateListener);
birthdateMonthDropdown.addActionListener(birthdateListener);
birthdateYearDropdown.addActionListener(birthdateListener);
btnSignUp.addActionListener(new ActionListener() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
stmtServer1.setString(1, fname);
stmtServer1.setString(2, mname);
stmtServer1.setString(3, lname);
stmtServer1.setString(4, email);
stmtServer1.setString(5, username);
stmtServer1.setString(6, hashedPassword);
stmtServer1.setString(7, "CLIENT");
stmtServer1.setString(8, birthdateDay);
stmtServer1.setString(9, birthdateMonth);
stmtServer1.setString(10, birthdateYear);
stmtServer1.setString(11, age);
stmtServer1.executeUpdate();
// Insert into test table
stmtTest.setString(1, username);
stmtTest.executeUpdate();
stmtServer1.close();
stmtTest.close();
conn.close();
fnameact.setText("");
mnameact.setText("");
lnameact.setText("");
emailact.setText("");
userr.setText("");
passwo.setText("");
f.dispose();
loginFrame.setVisible(true);
e1.printStackTrace();
JOptionPane.showMessageDialog(null, e1);
}
});
f.getContentPane().add(btnSignUp);
f.getContentPane().add(backgroundLabel);
f.setVisible(true);
return con;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(800, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
btnMovies_1_1.addActionListener(new ActionListener() {
LibraryFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnMovies_1_1);
f.getContentPane().add(btnMovies_1_2);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(movieComboBox);
JButton searchButton = new JButton("Search");
f.getContentPane().add(searchButton);
searchButton.addActionListener(new ActionListener() {
});
btnNewButton_1_3.setFocusable(false);
btnNewButton_1_3.addActionListener(new ActionListener() {
kidsFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1_3);
btnNewButton.addActionListener(new ActionListener() {
loginFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1_5.addActionListener(new ActionListener() {
horrorFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1_5);
btnNewButton_1_1.addActionListener(new ActionListener() {
f.dispose();
});
f.getContentPane().add(btnNewButton_1_1);
btnNewButton_1_8.addActionListener(new ActionListener() {
comedyFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1_8);
f.getContentPane().add(panel);
imageLabel.setHorizontalAlignment(JLabel.CENTER);
imageLabel.setIcon(images[currentImageIndex]);
panel.add(imageLabel, BorderLayout.CENTER);
@Override
imageLabel.setIcon(images[currentImageIndex]);
});
timer.start();
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
}
private JFrame createRentFrame(String username) {
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.setSize(1069, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
btnNewButton_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "150"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
// Prepare the SQL query
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error: " + ex.getMessage());
});
f.getContentPane().add(btnNewButton_1_1);
lblTrolls.setContentAreaFilled(false);
lblTrolls.setBorderPainted(false);
lblTrolls.setForeground(Color.BLACK);
lblTrolls.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTrolls);
f.getContentPane().add(lblTitle_1);
JButton lblR = new JButton("RATATOUILLE");
lblR.setContentAreaFilled(false);
lblR.setBorderPainted(false);
lblR.setForeground(Color.BLACK);
lblR.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblR);
lblWreckitRalph.setContentAreaFilled(false);
lblWreckitRalph.setBorderPainted(false);
lblWreckitRalph.setForeground(Color.BLACK);
lblWreckitRalph.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblWreckitRalph);
JLabel lblTitle_3 = new JLabel("Title:");
f.getContentPane().add(lblTitle_3);
lblTheAngryBirds.setContentAreaFilled(false);
lblTheAngryBirds.setBorderPainted(false);
lblTheAngryBirds.setForeground(Color.BLACK);
lblTheAngryBirds.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTheAngryBirds);
f.getContentPane().add(lblTitle_2);
lblRating_1.setForeground(Color.BLACK);
lblRating_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13));
f.getContentPane().add(lblRating_1);
lblRating.setForeground(Color.BLACK);
f.getContentPane().add(lblRating);
lblRating_2.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_2);
lblRating_3.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_3);
btnNewButton_1_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String title = "TROLLS"; // Replace lblTheAngryBirds with the appropriate label for
the movie title
String price = "150"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_1);
btnNewButton_1_1_2.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "150"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
// Establish the connection
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
} catch (SQLException | ClassNotFoundException ex) {
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_2);
f.getContentPane().add(lblTitle);
btnNewButton_1_1_3.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "150"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_3);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
pictureLabel2.setIcon(new
ImageIcon(imageIcon2.getImage().getScaledInstance(pictureLabel2.getWidth(),
pictureLabel2.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel2);
pictureLabel3.setIcon(new
ImageIcon(imageIcon3.getImage().getScaledInstance(pictureLabel3.getWidth(),
pictureLabel3.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel3);
JLabel pictureLabel4 = new JLabel();
pictureLabel4.setIcon(new
ImageIcon(imageIcon4.getImage().getScaledInstance(pictureLabel4.getWidth(),
pictureLabel4.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel4);
f.getContentPane().add(lblKids);
f.getContentPane().add(lblCinemasaya);
btnNewButton_1.addActionListener(new ActionListener() {
MenuFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().setComponentZOrder(backgroundLabel,
f.getContentPane().getComponentCount() - 1);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1069, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
btnNewButton_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "175"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
lblCharlieChaplin.setBorderPainted(false);
lblCharlieChaplin.setForeground(Color.BLACK);
lblCharlieChaplin.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblCharlieChaplin);
lblMrBeansHoliday.setContentAreaFilled(false);
lblMrBeansHoliday.setBorderPainted(false);
lblMrBeansHoliday.setForeground(Color.BLACK);
lblMrBeansHoliday.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblMrBeansHoliday);
lblHomeAlone.setBorderPainted(false);
lblHomeAlone.setContentAreaFilled(false);
lblHomeAlone.setForeground(Color.BLACK);
lblHomeAlone.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblHomeAlone);
lblBilltyMadison.setContentAreaFilled(false);
lblBilltyMadison.setBorderPainted(false);
lblBilltyMadison.setForeground(Color.BLACK);
lblBilltyMadison.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblBilltyMadison);
f.getContentPane().add(lblRating_1);
lblRating.setForeground(Color.BLACK);
f.getContentPane().add(lblRating);
lblRating_2.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_2);
lblRating_3.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_3);
f.getContentPane().add(lblTitle_3);
btnNewButton_1_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "175"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_1);
btnNewButton_1_1_2.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "175"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_2);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblTitle_2);
JLabel lblTitle_1 = new JLabel("Title:");
f.getContentPane().add(lblTitle_1);
btnNewButton_1_1_3.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "175"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_3);
f.getContentPane().add(btnNewButton_1_1);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
pictureLabel2.setIcon(new
ImageIcon(imageIcon2.getImage().getScaledInstance(pictureLabel2.getWidth(),
pictureLabel2.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel2);
pictureLabel3.setIcon(new
ImageIcon(imageIcon3.getImage().getScaledInstance(pictureLabel3.getWidth(),
pictureLabel3.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel3);
pictureLabel4.setIcon(new
ImageIcon(imageIcon4.getImage().getScaledInstance(pictureLabel4.getWidth(),
pictureLabel4.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel4);
f.getContentPane().add(lblKids);
f.getContentPane().add(lblCinemasaya);
btnNewButton_1.addActionListener(new ActionListener() {
MenuFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().setComponentZOrder(backgroundLabel,
f.getContentPane().getComponentCount() - 1);
lblTitle_3_1.setForeground(Color.BLACK);
f.getContentPane().add(lblTitle_3_1);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1069, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
btnNewButton_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String title = "THE NUN"; // Replace lblTheAngryBirds with the appropriate label for
the movie title
String price = "250"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1);
lblTalkToMe.setForeground(Color.BLACK);
lblTalkToMe.setBorderPainted(false);
lblTalkToMe.setForeground(Color.BLACK);
lblTalkToMe.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTalkToMe);
lblTheConjuring.setForeground(Color.BLACK);
lblTheConjuring.setContentAreaFilled(false);
lblTheConjuring.setBorderPainted(false);
lblTheConjuring.setForeground(Color.BLACK);
lblTheConjuring.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTheConjuring);
lblWinnieThePooh.setForeground(Color.BLACK);
lblWinnieThePooh.setFont(new Font("Tahoma", Font.BOLD, 14));
lblWinnieThePooh.setContentAreaFilled(false);
lblWinnieThePooh.setBorderPainted(false);
lblWinnieThePooh.setForeground(Color.BLACK);
lblWinnieThePooh.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblWinnieThePooh);
lblTheNun.setForeground(Color.BLACK);
lblTheNun.setContentAreaFilled(false);
lblTheNun.setBorderPainted(false);
lblTheNun.setForeground(Color.BLACK);
lblTheNun.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTheNun);
f.getContentPane().add(lblRating_1);
lblRating.setForeground(Color.BLACK);
f.getContentPane().add(lblRating);
lblRating_2.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_2);
lblRating_3.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_3);
f.getContentPane().add(lblTitle_3);
btnNewButton_1_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String title = "TALK TO ME"; // Replace lblTheAngryBirds with the appropriate label
for the movie title
String price = "250"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_1);
btnNewButton_1_1_2.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String title = "WINNIE THE POOH"; // Replace lblTheAngryBirds with the appropriate
label for the movie title
String price = "250"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
// Open the library frame and dispose the current frame
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_2);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblTitle_2);
btnNewButton_1_1_3.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "250"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_3);
f.getContentPane().add(btnNewButton_1_1);
f.getContentPane().add(pictureLabel1);
pictureLabel2.setIcon(new
ImageIcon(imageIcon2.getImage().getScaledInstance(pictureLabel2.getWidth(),
pictureLabel2.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel2);
pictureLabel3.setIcon(new
ImageIcon(imageIcon3.getImage().getScaledInstance(pictureLabel3.getWidth(),
pictureLabel3.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel3);
pictureLabel4.setIcon(new
ImageIcon(imageIcon4.getImage().getScaledInstance(pictureLabel4.getWidth(),
pictureLabel4.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel4);
f.getContentPane().add(lblCinemasaya);
btnNewButton_1.addActionListener(new ActionListener() {
MenuFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().setComponentZOrder(backgroundLabel,
f.getContentPane().getComponentCount() - 1);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1069, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
btnNewButton_1_1.addActionListener(new ActionListener() {
String title = "ONE DAY"; // Replace lblTheAngryBirds with the appropriate label for
the movie title
String price = "190"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1);
lblTheNotebook.setForeground(Color.BLACK);
lblTheNotebook.setContentAreaFilled(false);
lblTheNotebook.setBorderPainted(false);
lblTheNotebook.setForeground(Color.BLACK);
lblTheNotebook.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTheNotebook);
lblLoveWhisper.setForeground(Color.BLACK);
lblLoveWhisper.setContentAreaFilled(false);
lblLoveWhisper.setBorderPainted(false);
lblLoveWhisper.setForeground(Color.BLACK);
lblLoveWhisper.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblLoveWhisper);
lblOneDay.setForeground(Color.BLACK);
lblOneDay.setContentAreaFilled(false);
lblOneDay.setBorderPainted(false);
lblOneDay.setForeground(Color.BLACK);
lblOneDay.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
}
});
f.getContentPane().add(lblOneDay);
lblTheFaultIn.setForeground(Color.BLACK);
lblTheFaultIn.setContentAreaFilled(false);
lblTheFaultIn.setBorderPainted(false);
lblTheFaultIn.setForeground(Color.BLACK);
lblTheFaultIn.addActionListener(new ActionListener() {
rentFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblTheFaultIn);
lblRating_1.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_1);
lblRating.setForeground(Color.BLACK);
f.getContentPane().add(lblRating);
JLabel lblRating_2 = new JLabel("Price: 190");
lblRating_2.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_2);
lblRating_3.setForeground(Color.BLACK);
f.getContentPane().add(lblRating_3);
f.getContentPane().add(lblTitle_3);
btnNewButton_1_1_1.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String title = "THE FAULT OF OUR STARS"; // Replace lblTheAngryBirds with the
appropriate label for the movie title
String price = "190"; // Replace lblPrice with the appropriate label for the price
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_1);
btnNewButton_1_1_2.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String price = "190"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
}
}
});
f.getContentPane().add(btnNewButton_1_1_2);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblTitle_2);
f.getContentPane().add(lblTitle_1);
btnNewButton_1_1_3.addActionListener(new ActionListener() {
if (response == JOptionPane.YES_OPTION) {
String title = "CAN'T HELP FALLING INLOVE"; // Replace lblTheAngryBirds with the
appropriate label for the movie title
String price = "190"; // Replace lblPrice with the appropriate label for the price
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
} else {
// Close resources
pst.close();
conn.close();
// Open the library frame and dispose the current frame
libraryFrame.setVisible(true);
f.dispose();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton_1_1_3);
f.getContentPane().add(btnNewButton_1_1);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
pictureLabel2.setIcon(new
ImageIcon(imageIcon2.getImage().getScaledInstance(pictureLabel2.getWidth(),
pictureLabel2.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel2);
pictureLabel3.setIcon(new
ImageIcon(imageIcon3.getImage().getScaledInstance(pictureLabel3.getWidth(),
pictureLabel3.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel3);
pictureLabel4.setIcon(new
ImageIcon(imageIcon4.getImage().getScaledInstance(pictureLabel4.getWidth(),
pictureLabel4.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel4);
f.getContentPane().add(lblKids);
f.getContentPane().add(lblCinemasaya);
btnNewButton_1.addActionListener(new ActionListener() {
MenuFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().setComponentZOrder(backgroundLabel,
f.getContentPane().getComponentCount() - 1);
return f;
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
JLabel lblNewLabel_1 = new JLabel("<html><div style='text-align: LEFT'>After the Bergens invade
Troll Village, Poppy, the happiest Troll ever born, and the curmudgeonly Branch set off on a journey
to rescue her friends. When their village is invaded by the grumpy Bergens, two mismatched friends
must work together in perfect harmony to save the day.");
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblDuration);
f.getContentPane().add(lblCinemasaya);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
}
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
// Open the library frame
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
btnSignUp.addActionListener(new ActionListener() {
});
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
JLabel lblGenre = new JLabel("GENRE:");
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
JLabel lblNewLabel_1 = new JLabel("<html><div style='text-align: LEFT'>A rat named Remy dreams
of becoming a great chef despite his family's wishes, and the obvious problem of being a rat in a
decidedly rodent-phobic profession. When fate places Remy in the sewers of Paris, he finds himself
ideally situated beneath a restaurant made famous by his culinary hero, Auguste Gusteau.");
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
JLabel lblDuration = new JLabel("DURATION:");
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
}
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
btnSignUp.addActionListener(new ActionListener() {
});
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
JLabel lblNewLabel_1 = new JLabel("<html><div style='text-align: LEFT'> (born April 16, 1889,
London, England\u2014died December 25, 1977, Corsier-sur-Vevey, Switzerland) was a British
comedian, producer, writer, director, and composer who is widely regarded as the greatest comic
artist of the screen and one of the most important figures in motion-picture history.");
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
}
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
// Open the library frame
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
ImageIcon originalImageIcon = new ImageIcon(getClass().getResource("/bg.jpg"));
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
JOptionPane.showMessageDialog(null, "Record Not Added. Please try again.");
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
}
});
f.getContentPane().add(btnNewButton_1);
btnSignUp.addActionListener(new ActionListener() {
});
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
}
});
f.getContentPane().add(btnNewButton_1);
btnSignUp.addActionListener(new ActionListener() {
});
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
JLabel lblDuration = new JLabel("DURATION:");
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
}
String title = lblTheAngryBirds.getText().replace("TITLE: ", "").trim();
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
JOptionPane.showMessageDialog(null, "Record Not Added. Please try again.");
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
}
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
// Prepare the SQL query
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
// Execute the query
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error: " + ex.getMessage());
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
}
private JFrame createRent24Frame(String username) {
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
JLabel lblTheAngryBirds = new JLabel("The Conjuring");
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
JLabel lblGenre = new JLabel("GENRE:");
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
JLabel lblDuration = new JLabel("DURATION:");
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
}
String title = lblTheAngryBirds.getText().replace("TITLE: ", "").trim();
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
JLabel lblNewLabel = new JLabel("DESCRIPTION:");
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
JLabel pictureLabel1 = new JLabel();
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
// Establish the connection
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
}
// Clear the input fields
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
JLabel backgroundLabel = new JLabel(backgroundImage);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(2, title);
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
JLabel label = new JLabel("New label");
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(1100, 700);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setLocationRelativeTo(null);
lblhm.setForeground(Color.BLACK);
f.getContentPane().add(lblhm);
JLabel lblKids = new JLabel("ROMANCE");
lblKids.setForeground(Color.BLACK);
f.getContentPane().add(lblKids);
lblTheAngryBirds.setForeground(Color.BLACK);
f.getContentPane().add(lblTheAngryBirds);
lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);
f.getContentPane().add(lblNewLabel_1);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(lblTitle);
f.getContentPane().add(lblPrice);
f.getContentPane().add(lblGenre);
f.getContentPane().add(lblDuration);
pictureLabel1.setIcon(new
ImageIcon(imageIcon1.getImage().getScaledInstance(pictureLabel1.getWidth(),
pictureLabel1.getHeight(), Image.SCALE_SMOOTH)));
f.getContentPane().add(pictureLabel1);
f.getContentPane().add(lblCinemasaya);
btnNewButton.addActionListener(this);
btnNewButton.addActionListener(new ActionListener() {
int response = JOptionPane.showConfirmDialog(f, "Are you sure you want to rent this
movie?", "CONFIRMATION", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
String sql = "INSERT INTO test(Username, user_title, user_price) VALUES (?, ?, ?)";
pst.setString(3, price);
if (rowsAffected > 0) {
lblTheAngryBirds.setText("TITLE: ");
lblPrice.setText("PRICE: ");
libraryFrame.setVisible(true);
f.dispose();
} else {
lblTheAngryBirds.setText("");
lblPrice.setText("");
// Close resources
pst.close();
conn.close();
ex.printStackTrace();
});
f.getContentPane().add(btnNewButton);
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
f.getContentPane().add(backgroundLabel);
f.getContentPane().add(label);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(600, 600);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
btnX.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnX);
int userId = getUserId(username);
f.getContentPane().add(lblNewLabel_1);
lblNewLabel_2_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_1);
f.getContentPane().add(btnLogOut);
btnNewButton.addActionListener(new ActionListener() {
accountFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton);
f.getContentPane().add(lblNewLabel_2);
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(frontLabel);
f.getContentPane().add(lblNewLabel);
f.dispose();
return f;
}
private int getUserId(String username) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pstmt.setString(1, username);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
userId = rs.getInt("id");
ex.printStackTrace();
return userId;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
// Create a scrollable ResultSet
pst.setString(1, username);
ResultSet rs = pst.executeQuery();
rs.last();
rs.beforeFirst();
int i = 0;
while (rs.next()) {
data[i][0] = rs.getString("user_title");
data[i][1] = rs.getString("user_price");
i++;
rs.close();
pst.close();
conn.close();
ex.printStackTrace();
return data;
}
private JFrame createLibraryFrame(String username) {
f.getContentPane().setBackground(Color.BLACK);
f.setSize(795, 769);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
f.getContentPane().add(layeredPane);
layeredPane.add(scrollPane, Integer.valueOf(1));
btnMovies_1_1.setBackground(Color.WHITE);
layeredPane.add(btnMovies_1_1, Integer.valueOf(1));
JButton btnMovies_1_2 = new JButton("HOME");
btnMovies_1_2.addActionListener(new ActionListener() {
MoviesFrame.setVisible(true);
f.dispose();
});
layeredPane.add(btnMovies_1_2, Integer.valueOf(1));
lblNewLabel_2_2.setForeground(Color.WHITE);
layeredPane.add(lblNewLabel_2_2, Integer.valueOf(1));
backgroundLabel.setIcon(new ImageIcon(new
ImageIcon(this.getClass().getResource("/MENU.jpg")).getImage().getScaledInstance(795, 769,
Image.SCALE_SMOOTH)));
layeredPane.add(backgroundLabel,
Integer.valueOf(0)); // Add the background label to the lowest layer
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(635, 436);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
stmt.setString(1, username);
ResultSet rs = stmt.executeQuery();
lblAge.setForeground(Color.WHITE);
lblFirstName.setForeground(Color.WHITE);
lblLastName.setForeground(Color.WHITE);
JLabel lblBirthdate = new JLabel("Birth Date: " + " " + birthdateDay + " " +
birthdateMonth + ", " + birthdateYear);
lblBirthdate.setForeground(Color.WHITE);
lblMiddleName.setForeground(Color.WHITE);
lblEmail.setForeground(Color.WHITE);
f.getContentPane().add(lblAge);
f.getContentPane().add(lblFirstName);
f.getContentPane().add(lblLastName);
f.getContentPane().add(lblBirthdate);
f.getContentPane().add(lblMiddleName);
f.getContentPane().add(lblEmail);
} else {
// Close resources
rs.close();
stmt.close();
conn.close();
e.printStackTrace();
JOptionPane.showMessageDialog(null, e);
}
JButton btnNewButton_1 = new JButton("<");
btnNewButton_1.addActionListener(new ActionListener() {
moviesFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(btnNewButton_1);
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(frontLabel);
return f;
}
private JFrame createDashboardFrame(String username) {
f.getContentPane().setBackground(Color.BLACK);
f.setSize(614, 373);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
btnNewButton_1.addActionListener(new ActionListener() {
TotaluserFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1);
btnNewButton_1_2.addActionListener(new ActionListener() {
TransactionFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton_1_2);
lblNewLabel_2_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_2);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(btnLogOut);
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(frontLabel);
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(614, 597);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
Image frontImage = new
ImageIcon(this.getClass().getResource("/MENU.jpg")).getImage();
String[] columnNames = {"ID", "Username", "First Name", "Middle Name", "Last Name"};
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
int id = rs.getInt("id");
ex.printStackTrace();
f.getContentPane().add(scrollPane);
JLabel lblNewLabel_2_3_1_4_2 = new JLabel("Rent Movies");
lblNewLabel_2_3_1_4_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_2);
btnNewButton.addActionListener(new ActionListener() {
DashboardFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton);
lblNewLabel_2_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_2);
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(frontLabel);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(separator_2_2);
f.dispose();
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(826, 597);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
ex.printStackTrace();
f.getContentPane().add(scrollPane);
btnNewButton.addActionListener(new ActionListener() {
DashboardFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton);
lblNewLabel_2_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_2);
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(frontLabel);
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(separator_2_2);
f.dispose();
return f;
f.getContentPane().setBackground(Color.BLACK);
f.setSize(650, 597);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(null);
f.setResizable(false);
f.setLocationRelativeTo(null);
lblNewLabel_2_3_1_4_1_1_5_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_5_1);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_5_4);
lblNewLabel_2_3_1_4_1_1_5_3.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_5_3);
lblNewLabel_2_3_1_4_1_1_5_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_5_2);
f.getContentPane().add(separator_2_3_2);
lblNewLabel_2_3_1_4_1_1_5.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_5);
separator_1.setOrientation(SwingConstants.VERTICAL);
f.getContentPane().add(separator_1);
JSeparator separator_1_1 = new JSeparator();
separator_1_1.setOrientation(SwingConstants.VERTICAL);
f.getContentPane().add(separator_1_1);
f.getContentPane().add(separator_2_3_5);
f.getContentPane().add(separator_2_3_3);
lblNewLabel_2_3_1_4_2_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_2_2);
lblNewLabel_2_3_1_4_1_1_4.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_4);
lblNewLabel_2_3_1_4_1_1_3.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_3);
JLabel lblNewLabel_2_3_1_4_1_1_2 = new JLabel("3.");
lblNewLabel_2_3_1_4_1_1_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_2);
lblNewLabel_2_3_1_4_1_1_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1_1);
lblNewLabel_2_3_1_4_1_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1_1);
f.getContentPane().add(separator_2_3_4);
f.getContentPane().add(separator_2_3_1);
f.getContentPane().add(separator_2_3_6);
JSeparator separator = new JSeparator();
separator.setOrientation(SwingConstants.VERTICAL);
f.getContentPane().add(separator);
f.getContentPane().add(separator_2_1);
f.getContentPane().add(separator_2_4);
f.getContentPane().add(separator_2);
f.getContentPane().add(separator_2_5);
f.getContentPane().add(separator_2_3);
lblNewLabel_2_3_1_4_1.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_1);
JLabel lblNewLabel_2_3_1_4_2 = new JLabel("Movie Title");
lblNewLabel_2_3_1_4_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_3_1_4_2);
btnNewButton.addActionListener(new ActionListener() {
DashboardFrame.setVisible(true);
f.dispose();
});
f.getContentPane().add(btnNewButton);
lblNewLabel_2_2.setForeground(Color.WHITE);
f.getContentPane().add(lblNewLabel_2_2);
frontLabel.setIcon(new ImageIcon(frontImage));
f.getContentPane().add(lblNewLabel);
f.getContentPane().add(separator_2_2);
f.dispose();
return f;
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
sb.append(String.format("%02x", b));
}
return sb.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
rentFrame.setVisible(true);
parentFrame.dispose();
} else if (searchQuery.equalsIgnoreCase("TROLLS")) {
rent1Frame.setVisible(true);
parentFrame.dispose();
rent3Frame.setVisible(true);
parentFrame.dispose();
} else if (searchQuery.equalsIgnoreCase("RATATOUILLE")) {
rent4Frame.setVisible(true);
parentFrame.dispose();
rent11Frame.setVisible(true);
parentFrame.dispose();
} else if (searchQuery.equalsIgnoreCase("HOME ALONE")) {
rent12Frame.setVisible(true);
parentFrame.dispose();
rent13Frame.setVisible(true);
parentFrame.dispose();
rent14Frame.setVisible(true);
parentFrame.dispose();
rent21Frame.setVisible(true);
parentFrame.dispose();
rent22Frame.setVisible(true);
parentFrame.dispose();
rent23Frame.setVisible(true);
parentFrame.dispose();
rent24Frame.setVisible(true);
parentFrame.dispose();
rent31Frame.setVisible(true);
parentFrame.dispose();
rent32Frame.setVisible(true);
parentFrame.dispose();
rent33Frame.setVisible(true);
parentFrame.dispose();
rent34Frame.setVisible(true);
parentFrame.dispose();
} else {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database_name", "root", "");
pstmt.setString(1, username);
pstmt.setString(2, userType);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
if ("ADMIN".equals(userTypeFromDB)) {
if (password.equals(hashedPasswordFromDB)) {
dashboardFrame.setVisible(true);
loginFrame.dispose();
} else {
} else {
if (hashedPasswordFromDB.equals(hashedPassword)) {
moviesFrame.setVisible(true);
loginFrame.dispose();
} else {
} else {
JOptionPane.showMessageDialog(null, "User not found");
con.close();
} catch (Exception e) {
e.printStackTrace();
linesFrame = createMoviesframe(username);
loginFrame.setVisible(false);
linesFrame.setVisible(true);
frameToClose.dispose();
loginFrame.setVisible(true);
return null;
@Override