NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;



public class Booking extends JFrame {

private JTextField book_id;
private JTextField book_name;
private JTextField book_price;

private static final long serialVersionUID = 1;
private JPanel contentPane;

/**
* Launch the application.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
Booking frame = new Booking();
frame.setVisible(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
}




public Booking()
{

JLabel pylabel = new JLabel("Number of clicks: 0 ");
JFrame pyframe = new JFrame();
JButton pybutton = new JButton("Click Me");

setIconImage(Toolkit.getDefaultToolkit().getImage("C:\e.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(450, 190, 1014, 597);
setResizable(false);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabel lblNewLabel = new JLabel("Rezerve a Book");
lblNewLabel.setForeground(Color.BLACK);
lblNewLabel.setFont(new Font("Times New Roman", Font.PLAIN, 26));
lblNewLabel.setBounds(423, 13, 273, 93);
contentPane.add(lblNewLabel);

JButton btnNewButtonBook1 = new JButton("Java Swing ");
JButton btnNewButtonBook2 = new JButton("Python 2");
JButton btnNewButtonBook3 = new JButton("Database ERD");
JButton btnNewButtonBook4 = new JButton("Exit");
JButton btnNewButtonBook5 = new JButton("Python 2");

// btnNewButtonBook1 = new JButton("Java Swing");
btnNewButtonBook1.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButtonBook1.setBounds(435, 192, 162, 73);

// btnNewButtonBook2 = new JButton("Python 2");
btnNewButtonBook2.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButtonBook2.setBounds(435, 92, 162, 73);

// btnNewButtonBook5 = new JButton("Python Other Button");
btnNewButtonBook5.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButtonBook5.setBounds(435, 92, 162, 73);

// btnNewButtonBook3 = new JButton("Database ERD");
btnNewButtonBook3.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButtonBook3.setBounds(435, 300, 162, 73);


btnNewButtonBook4.setForeground(new Color(0, 0, 0));
btnNewButtonBook4.setBounds(435, 400, 162, 73);
btnNewButtonBook4.setBackground(UIManager.getColor("Button.disabledForeground"));
btnNewButtonBook4.setFont(new Font("Tahoma", Font.PLAIN, 39));



book_id = new JTextField();
book_id.setFont(new Font("Tahoma", Font.PLAIN, 32));
book_id.setBounds(214, 235, 228, 50);
contentPane.add(book_id);
book_id.setColumns(10);

book_name = new JTextField();
book_name.setFont(new Font("Tahoma", Font.PLAIN, 32));
book_name.setBounds(214, 235, 228, 50);
contentPane.add(book_name);
book_name.setColumns(10);

book_price = new JTextField();
book_price.setFont(new Font("Tahoma", Font.PLAIN, 32));
book_price.setBounds(214, 235, 228, 50);
contentPane.add(book_price);
book_price.setColumns(10);


JLabel lblbookid = new JLabel("Book ID");
lblbookid.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblbookid.setBounds(58, 152, 99, 43);
contentPane.add(lblbookid);

JLabel lblbookname = new JLabel("Book Name");
lblbookname.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblbookname.setBounds(58, 243, 110, 29);
contentPane.add(lblbookname);

JLabel lblbookprice = new JLabel("Book Price");
lblbookprice.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblbookprice.setBounds(58, 324, 124, 36);
contentPane.add(lblbookprice);

btnNewButtonBook4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int a = JOptionPane.showConfirmDialog(btnNewButtonBook4, "Are you sure?");
// JOptionPane.setRootFrame(null);
if (a == JOptionPane.YES_OPTION) {
dispose();
UserLogin obj = new UserLogin();
obj.setTitle("Student-Login");
obj.setVisible(true);
}
dispose();
UserLogin obj = new UserLogin();

obj.setTitle("Student-Login");
obj.setVisible(true);

}
});

btnNewButtonBook1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int a = JOptionPane.showConfirmDialog(btnNewButtonBook1, "Are you sure to reserve Java Swing Book?");
if (a == JOptionPane.YES_OPTION) {
dispose();
Booking obj = new Booking();
obj.setTitle("Student-Login");
obj.setVisible(true);
}


}});



btnNewButtonBook5.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent e)
{
String bookid = book_id.getText();
String bookname = book_name.getText();
String bookprice = book_price.getText();

int a = JOptionPane.showConfirmDialog(btnNewButtonBook5, "Are you sure to reserve python book?");
if (a == JOptionPane.YES_OPTION)
{
try
{
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/klevi_java", "root", "root");

String query = "INSERT INTO account values('" + book_id + "','" + book_name + "','" + book_price + "')";

Statement sta = connection.createStatement();
int x = sta.executeUpdate(query);
if (x == 0)
{
JOptionPane.showMessageDialog(btnNewButtonBook5, "This is alredy exist");
}
else
{
JOptionPane.showMessageDialog(btnNewButtonBook5, "Welcome Klevi");
}
connection.close();
}
catch (Exception exception)
{
exception.printStackTrace();
}

int k = JOptionPane.showConfirmDialog(btnNewButtonBook5, "You are registred, do you want to login to system now?");
if (k == JOptionPane.YES_OPTION)
{
/*
dispose();
UserLogin obj = new UserLogin();
obj.setTitle("Student-Login");
obj.setVisible(true);
*/
JButton button = new JButton("Click Me");
button.addActionListener(this);

// the panel with the button and text
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEmptyBorder(30, 30, 10, 30));
panel.setLayout(new GridLayout(0, 1));
panel.add(button);
panel.add(pylabel);

// set up the frame and display it
pyframe.add(panel, BorderLayout.CENTER);
pyframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pyframe.setTitle("GUI");
pyframe.pack();
pyframe.setVisible(true);
}
}



}
});






btnNewButtonBook1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int a = JOptionPane.showConfirmDialog(btnNewButtonBook3, "Are you sure to reserve Java Swing Book?");
if (a == JOptionPane.YES_OPTION) {
dispose();
Booking obj = new Booking();
obj.setTitle("Student-Login");
obj.setVisible(true);
}


}});




contentPane.add(btnNewButtonBook1);
contentPane.add(btnNewButtonBook2);
contentPane.add(btnNewButtonBook3);
contentPane.add(btnNewButtonBook4);

}
}


     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.