Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bookborrowing;
- import javax.swing.*; //JComponents
- import java.awt.*;
- import java.awt.event.*;
- public class BookBorrowing extends JFrame implements ActionListener {
- //declaring JComponents
- JLabel lblTitle,lBG;
- JButton bAddBook,bViewBook,bReturnBook,bIssueBook,
- bLogout;
- // issuebook is my Borrowed Book
- JPanel panel, addbook, viewbook, returnbook, issuebook;
- //construct / instantiate conponents
- public BookBorrowing() {
- JFrame frame = new JFrame("Book Borrowing System");
- panel = new JPanel();
- panel.setLayout(null);
- panel.setBackground(Color.YELLOW);
- panel.setVisible(true);
- addbook = new JPanel();
- addbook.setLayout(null);
- addbook.setBackground(Color.YELLOW);
- addbook.setVisible(false);
- issuebook = new JPanel();
- issuebook.setLayout(null);
- issuebook.setBackground(Color.YELLOW);
- issuebook.setVisible(false);
- viewbook = new JPanel();
- viewbook.setLayout(null);
- viewbook.setBackground(Color.YELLOW);
- viewbook.setVisible(false);
- returnbook = new JPanel();
- returnbook.setLayout(null);
- returnbook.setBackground(Color.YELLOW);
- returnbook.setVisible(false);
- //Container c = getContentPane();
- JLabel lblBG = new JLabel();
- lblBG.setBackground(Color.YELLOW);
- lblTitle = new JLabel(" BOOK BORROWING SYSTEM ");
- lblTitle.setFont(new Font("Arial Black",Font.BOLD,27));
- lblTitle.setForeground(Color.BLACK);
- bAddBook = new JButton("Add Book/s");
- bAddBook.setBackground(new Color(204,0,0));
- bAddBook.setFont(new Font("Calibri",Font.BOLD,20));
- bAddBook.setForeground(Color.WHITE);
- bViewBook = new JButton("View Book/s");
- bViewBook.setBackground(new Color(204,0,0));
- bViewBook.setFont(new Font("Calibri",Font.BOLD,20));
- bViewBook.setForeground(Color.WHITE);
- bReturnBook = new JButton("Return Book/s");
- bReturnBook.setBackground(new Color(204,0,0));
- bReturnBook.setFont(new Font("Calibri",Font.BOLD,20));
- bReturnBook.setForeground(Color.WHITE);
- bIssueBook = new JButton("Borrow Book/s");
- bIssueBook .setBackground(new Color(204,0,0));
- bIssueBook .setFont(new Font("Calibri",Font.BOLD,20));
- bIssueBook .setForeground(Color.WHITE);
- bLogout = new JButton("LOG OUT");
- bLogout .setBackground(new Color(204,0,0));
- bLogout .setFont(new Font("Calibri",Font.BOLD,20));
- bLogout .setForeground(Color.WHITE);
- //Placing Components on the JFrame
- //setBound(x,y,width,height)=>positioning
- //JLabel positioning
- panel.add(lblTitle);
- lblTitle.setBounds(300,80,500,40);
- //JButton positioning
- panel.add(bAddBook);
- bAddBook.setBounds(440,200,180,40);
- panel.add(bViewBook);
- bViewBook.setBounds(440,280,180,40);
- panel.add(bReturnBook);
- bReturnBook.setBounds(440,360,180,40);
- panel.add(bIssueBook);
- bIssueBook.setBounds(440,440,180,40);
- panel.add(bLogout);
- bLogout.setBounds(440,520,180,40);
- //button actionlistener
- bAddBook.addActionListener(this);
- bViewBook.addActionListener(this);
- bReturnBook.addActionListener(this);
- bIssueBook.addActionListener(this);
- bLogout.addActionListener(this);
- frame.add(panel);
- frame.setSize(1100,900);
- frame.setVisible( true );
- frame.setResizable(false);
- frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
- }//end of constructor
- public void actionPerformed (ActionEvent e ) {
- if (e.getSource()== bAddBook){
- panel.setVisible(false);
- addbook.setVisible(true);
- }
- if (e.getSource()== bViewBook){
- panel.setVisible(false);
- viewbook.setVisible(true);
- }
- if (e.getSource()== bReturnBook){
- panel.setVisible(false);
- returnbook.setVisible(true);
- }
- if (e.getSource()== bIssueBook){
- panel.setVisible(false);
- issuebook.setVisible(true);
- }
- }//end of action performed
- public static void main(String[] args) {
- BookBorrowing BB = new BookBorrowing();
- } // main method begins execution of Java application
- } // end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement