Friday, October 22, 2010

CHECKERS INTERFACE BY JOHN CHAMDIMBA


INSTRUCTIONS:

Ø  Load each and every part of the JGrasp java files into the compiler.
Ø  Run the program and you will see the interface of checkers/draught


MAIN OBJECTIVES
The primary aim of the interface was to see how to draw graphics using 2D Graphics and also how to import pictures into your drawings.
NB: the pieces on the checkers do not move but in my next chess publish I will publish the whole game where you can play either by the computer or with your friend

Process
After running the program this is the checkers interface which will be displayed on your screen.



HERE IS THE SOURCE CODE OF THE CHECKERS INTERFACE PROGRAM WRITTEN IN JAVA COMPUTER PROGRAMMING LANGUAGE
// PROGRAMMER:JOHN CHAMDIMBA
// BSc.MATHEMATICAL SCIENCES EDUCATION-STATISTICS AND COMPUTING
// PROGRAM:CHECKERS/DRAUGHT (C)2010


import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.Color;


 
public class draftJohnChamdimba {

 
public static void main(String[] args)
     {        

        MakeFrame frame =
new MakeFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.show();
     }     
   
}

 
class MakeFrame extends JFrame
 {
   
        
public MakeFrame()
     {           
       setSize(700, 742);     
      setLocation(500,60);
       setResizable(
true);     
       setTitle(
"DRAFT-------JOHN CHAMDIMBA--------");      

       MakePanel panel =
new MakePanel();
       panel.setLayout(
new BorderLayout());

  
       JPanel panelNijo=
new JPanel();
       panelNijo.setBackground(Color.red);   
      
       JButton button1=
new JButton("New Game");
       JButton button2=
new JButton("Help");
       JButton button3=
new JButton("Previous Game");
       JButton button4=
new JButton("Save Game");
  
      panelNijo.add(button1);
       panelNijo.add(button3);
       panelNijo.add(button4);
       panelNijo.add(button2);
      
       Container contentPane = getContentPane();
       contentPane.setLayout(
new BorderLayout());

       contentPane.add(panel,BorderLayout.CENTER);
       contentPane.add(panelNijo,BorderLayout.NORTH);

     }
 
 }

     
 
class MakePanel extends JPanel
 {
  
    ImageIcon picIcon =
new ImageIcon("D:\\fanta.png");
    Image picImage = picIcon.getImage();
   
    ImageIcon picIcon2 =
new ImageIcon("D:\\spesho.png");
    Image picImage2 = picIcon2.getImage();

   
public void paintComponent(Graphics g)
    {
       MakeFrame frame =
new MakeFrame();
      
int start1=0;
      
int start2=0;
      
int x=start1;
      
int y=start2;
      
int numberOfbox=8;
      
int sizeOfbox=85;
      
boolean paint=false;
      
      
super.paintComponent(g);
       Graphics2D g2 = (Graphics2D)g;      
      
for(int a=0;a<numberOfbox;a++)
       {
      
if(a%2==0)
        {paint=
false;}
      
else if(a%2==1)
        {paint=
true;} 
       x=start1;
      
for(int b=0;b<numberOfbox;b++)
        {               
       
if(paint==true)
        {
        g2.setPaint(Color.white);
        g2.fill(
new Rectangle2D.Double(x,y,sizeOfbox,sizeOfbox));
     
     
//line number one
        g2.drawImage(picImage, 15, 15, this);
        g2.drawImage(picImage, 190,15,
this);
        g2.drawImage(picImage, 350,15,
this);
        g2.drawImage(picImage, 530,15,
this);
       
     
//line number two
        g2.drawImage(picImage, 100,100, this);
        g2.drawImage(picImage, 280,100,
this);
        g2.drawImage(picImage, 450,100,
this);
        g2.drawImage(picImage, 615,100,
this);
      
      
//line number three
        g2.drawImage(picImage, 190,190, this);
        g2.drawImage(picImage, 355,190,
this);
        g2.drawImage(picImage, 530,190,
this);
        g2.drawImage(picImage, 20,190,
this);

        paint=
false;
        }
       
else
        {
        g2.setPaint(Color.black);
        g2.fill(
new Rectangle2D.Double(x,y,sizeOfbox,sizeOfbox));
      
      
//line number one back
        g2.drawImage(picImage2, 15, 530, this);
        g2.drawImage(picImage2, 187,530,
this);
        g2.drawImage(picImage2, 527,530,
this);
        g2.drawImage(picImage2, 350,530,
this);
       
       
//line number far back
         g2.drawImage(picImage2, 605,610, this);
         g2.drawImage(picImage2, 95,610,
this);
         g2.drawImage(picImage2, 445,610,
this);
         g2.drawImage(picImage2, 275,610,
this);
       
       
//line number three far front
         g2.drawImage(picImage2, 450,447, this);
         g2.drawImage(picImage2, 270,447,
this);
         g2.drawImage(picImage2, 100,447,
this);
         g2.drawImage(picImage2, 610,447,
this);
       

        paint=
true;
        }
        x+=sizeOfbox;
       }                      
        y+=sizeOfbox;
       }
    }
}
//END OF PROGRAM


CHESS INTERFACE BY JOHN CHAMDIMBA


INSTRUCTIONS:

Ø  Load each and every part of the JGrasp java files into the compiler.
Ø  Run the program and you will see the interface of chess


MAIN OBJECTIVES
The primary aim of the interface was to see how to draw graphics using 2D Graphics and also how to import pictures into your drawings.
NB: the pieces on the chessboard do not move but in my next chess publish I will publish the whole game where you can play either by the computer or with your friend.

Process
After running the program this is the chess interface which will be displayed on your screen.
.

HERE IS THE SOURCE CODE OF THE CHESS INTERFACE PROGRAM WRITTEN IN JAVA COMPUTER PROGRAMMING LANGUAGE


// PROGRAMMER:JOHN CHAMDIMBA
// BSc.MATHEMATICAL SCIENCES EDUCATION-STATISTICS AND COMPUTING
// PROGRAM:CHESS (C)2010

import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.Color;


 
public class chessJohnChamdimba {

 
public static void main(String[] args)
     {        

        MakeFrame frame =
new MakeFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.show();
     }     
   
}

 
class MakeFrame extends JFrame
 {
   
        
public MakeFrame()
     {           
       setSize(700, 742);     
       setLocation(500,60);
       setResizable(
true);     
       setTitle(
"CHESS-------JOHN CHAMDIMBA--------");      

       MakePanel panel =
new MakePanel();
       panel.setLayout(
new BorderLayout());

  
       JPanel panelNijo=
new JPanel();
       panelNijo.setBackground(Color.green); 
      
       JButton button1=
new JButton("New Game");
       JButton button2=
new JButton("Help");
       JButton button3=
new JButton("Previous Game");
       JButton button4=
new JButton("Save Game");
  
       panelNijo.add(button1);
       panelNijo.add(button3);
       panelNijo.add(button4);
       panelNijo.add(button2);
      
       Container contentPane = getContentPane();
       contentPane.setLayout(
new BorderLayout());

       contentPane.add(panel,BorderLayout.CENTER);
       contentPane.add(panelNijo,BorderLayout.NORTH);

     }
 
 }

     
 
class MakePanel extends JPanel
 {
  
    ImageIcon picIcon =
new ImageIcon("D:\\chess1\\bb.jpg");
    Image picImage = picIcon.getImage();
   
    ImageIcon picIcon2 =
new ImageIcon("D:\\chess1\\bc.jpg");
    Image picImage2 = picIcon2.getImage();
   
    ImageIcon picIcon3 =
new ImageIcon("D:\\chess1\\bk.jpg");
    Image picImage3 = picIcon3.getImage();
   
    ImageIcon picIcon4 =
new ImageIcon("D:\\chess1\\bp.jpg");
    Image picImage4 = picIcon4.getImage();

    ImageIcon picIcon5 =
new ImageIcon("D:\\chess1\\bh.jpg");
    Image picImage5 = picIcon5.getImage();
 
    ImageIcon picIcon6 =
new ImageIcon("D:\\chess1\\bq.jpg");
    Image picImage6 = picIcon6.getImage();
   
    ImageIcon picIcon7 =
new ImageIcon("D:\\chess1\\wb.jpg");
    Image picImage7 = picIcon7.getImage();
   
    ImageIcon picIcon12 =
new ImageIcon("D:\\chess1\\wcc.jpg");
    Image picImage12 = picIcon12.getImage();
   
    ImageIcon picIcon8 =
new ImageIcon("D:\\chess1\\wk.jpg");
    Image picImage8 = picIcon8.getImage();
   
    ImageIcon picIcon9 =
new ImageIcon("D:\\chess1\\wp.jpg");
    Image picImage9 = picIcon9.getImage();

    ImageIcon picIcon10 =
new ImageIcon("D:\\chess1\\wh.jpg");
    Image picImage10 = picIcon10.getImage();
 
    ImageIcon picIcon11 =
new ImageIcon("D:\\chess1\\wq.jpg");
    Image picImage11 = picIcon11.getImage();



   
public void paintComponent(Graphics g)
    {
       MakeFrame frame =
new MakeFrame();
      
int start1=0;
      
int start2=0;
      
int x=start1;
      
int y=start2;
      
int numberOfbox=8;
      
int sizeOfbox=85;
      
boolean paint=false;
      
      
super.paintComponent(g);
       Graphics2D g2 = (Graphics2D)g;      
      
for(int a=0;a<numberOfbox;a++)
       {
      
if(a%2==0)
       {paint=
false;}
      
else if(a%2==1)
        {paint=
true;} 
       x=start1;
      
for(int b=0;b<numberOfbox;b++)
        {               
       
if(paint==true)
        {
        g2.setPaint(Color.white);
        g2.fill(
new Rectangle2D.Double(x,y,sizeOfbox,sizeOfbox));
     
     
//line number one black
        g2.drawImage(picImage2, 15, 15, this);
        g2.drawImage(picImage, 190,15,
this);
        g2.drawImage(picImage6, 350,15,
this);
        g2.drawImage(picImage5, 530,15,
this);
       
          g2.drawImage(picImage5, 100, 15,
this);
          g2.drawImage(picImage3, 260,15,
this);
          g2.drawImage(picImage2, 600,15,
this);
          g2.drawImage(picImage, 440,15,
this);
       

     
//line number two black
        g2.drawImage(picImage4, 100,100, this);
        g2.drawImage(picImage4, 280,100,
this);
        g2.drawImage(picImage4, 450,100,
this);
        g2.drawImage(picImage4, 615,100,
this);
       
        g2.drawImage(picImage4, 10,100,
this);
        g2.drawImage(picImage4, 190,100,
this);
        g2.drawImage(picImage4, 350,100,
this);
        g2.drawImage(picImage4, 530,100,
this);
      

      
        paint=
false;
        }
       
else
        {
        g2.setPaint(Color.red);
        g2.fill(
new Rectangle2D.Double(x,y,sizeOfbox,sizeOfbox));
      
      
//line number one back white
        g2.drawImage(picImage9, 15, 530, this);
        g2.drawImage(picImage9, 187,530,
this);
        g2.drawImage(picImage9, 527,530,
this);
        g2.drawImage(picImage9, 350,530,
this);  
        g2.drawImage(picImage9, 100, 530,
this)
        g2.drawImage(picImage9, 267,530,
this);
        g2.drawImage(picImage9, 437,530,
this);
        g2.drawImage(picImage9, 610,530,
this);
       
      
//line number far back white
        g2.drawImage(picImage12, 605,610, this);
         g2.drawImage(picImage10, 95,610,
this);
         g2.drawImage(picImage7, 445,610,
this);
         g2.drawImage(picImage8, 275,610,
this);
       
         g2.drawImage(picImage12, 25,610,
this);
         g2.drawImage(picImage7,  185,610,
this);
         g2.drawImage(picImage11, 345,610,
this);
         g2.drawImage(picImage10, 540,610,
this);
    

        paint=
true;
       }
        x+=sizeOfbox;
       }                   
        y+=sizeOfbox;
       }
    }
}
//end of program

Tuesday, October 12, 2010

LIBRARY SYSTEM SOURCE CODE-JAVA BY JOHN CHAMDIMBA

// PROGRAMMER:JOHN CHAMDIMBA
// BSc.MATHEMATICAL SCIENCES EDUCATION-STATISTICS AND COMPUTING
// PROGRAM:UNIMA LIBRARY SYSTEM(c)2010
// JAVA PROGRAMMING LANGUAGE


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Color;
import java.io.*;
import javax.swing.JOptionPane;

public class Lib4 extends JFrame implements ActionListener
{
JFrame aFrame;
JFrame bFrame;
JFrame cFrame;
JFrame dFrame;


String cName;
String dName;
String eName;
String fName;
String gName;



public static void main(String[] args)
{
new Lib4();
}

JPanel viewPanel = new JPanel();
JTextArea pub = new JTextArea(100,200);

JTextField textf1 = new JTextField(25);
JTextField textf2 = new JTextField(25);
JTextField textf3 = new JTextField(25);
JTextField textf4 = new JTextField(25);
JTextField textf5 = new JTextField(25);
JTextField textf6 = new JTextField(25);
JTextField textf7 = new JTextField(25);


ImageIcon idIcon = new ImageIcon("D:\\Picture2.png");
JButton idButton = new JButton(idIcon);


JButton clear = new JButton("Clear");
JButton exitBtton = new JButton("Exit");
JButton save = new JButton("Save");
JButton viewInfoEntered = new JButton("View Info Entered");
JButton booking = new JButton("Bookings");
JButton back = new JButton("Return Book");

JButton BviewInfoEntered = new JButton("View Info Entered");
JButton Bsave = new JButton("Save");
JButton Bclear = new JButton("Clear");
JButton Bexit = new JButton("Exit");

JButton Cclear = new JButton("ClearName In File");
JButton Ccal = new JButton("Calculate Fine");
JButton Cexit = new JButton("Exit");

JButton exitButton = new JButton("Exit");


JLabel author = new JLabel("Enter Author/s");
JLabel serialNo = new JLabel("Enter Serial No.");
JLabel book = new JLabel("Enter Book Title");
JLabel publisher = new JLabel("Enter Publisher");
JLabel dateOfArrival = new JLabel("Date of arrival");
JLabel id = new JLabel("Received by");
JLabel tittle = new JLabel("WELCOME TO UNIMA LIBRARY");
JComboBox backCo;
JComboBox dalCo;
JComboBox item;
JComboBox dur;
JComboBox due;
JComboBox progCo;
JComboBox yearCo;


public Lib4()
{ this.setTitle("UNIMA LIBRARY SYSTEM");
this.setLocation(50,50);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(true);
this.setVisible(true);

JPanel myPanel = new JPanel();
author.setFont(new Font("Algerian",Font.BOLD,22));
serialNo.setFont(new Font("Algerian",Font.BOLD,22));
book.setFont(new Font("Algerian",Font.BOLD,22));
publisher.setFont(new Font("Algerian",Font.BOLD,22));
dateOfArrival.setFont(new Font("Algerian",Font.BOLD,22));
id.setFont(new Font("Algerian",Font.BOLD,22));
tittle.setFont(new Font("Algerian",Font.BOLD,22));
textf1.setFont(new Font("Venderna",Font.BOLD,15));
textf2.setFont(new Font("Venderna",Font.BOLD,15));
textf3.setFont(new Font("Venderna",Font.BOLD,15));
textf4.setFont(new Font("Venderna",Font.BOLD,15));
textf5.setFont(new Font("Venderna",Font.BOLD,15));

JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
panel2.setBackground(Color.white);
myPanel.setBackground(Color.blue);
myPanel.setLayout(new GridBagLayout());
panel3.setLayout(new BorderLayout());
viewPanel.setLayout(new BorderLayout());

textf4.setEditable(true);

panel2.add(tittle);
panel2.add(idButton);
idButton.setBackground(Color.BLUE);
idButton.setBorderPainted(false);
idButton.setContentAreaFilled(true);

clear.addActionListener(this);
exitBtton.addActionListener(this);
save.addActionListener(this);
viewInfoEntered.addActionListener(this);
booking.addActionListener(this);
back.addActionListener(this);

Bclear.addActionListener(this);
BviewInfoEntered.addActionListener(this);
Bexit .addActionListener(this);


Cclear.addActionListener(this);
Ccal.addActionListener(this);
Cexit .addActionListener(this);
exitButton .addActionListener(this);


addItem(myPanel,author, 0, 0, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf1, 1, 0, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,serialNo, 0, 1, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf2, 1, 1, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,book, 0, 2, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf3, 1, 2, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,publisher, 0, 3, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf4, 1, 3, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,dateOfArrival, 0, 4, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf5, 1, 4, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,clear, 0, 6, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,exitBtton, 1,6 , 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,save, 1, 7, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,viewInfoEntered, 0, 7, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,booking, 0, 8, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,back, 1, 8, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);


save.addMouseListener (new SaveListener());
Bsave.addMouseListener (new SaveListener());


panel3.add(panel2,BorderLayout.NORTH);
panel3.add(myPanel,BorderLayout.CENTER);

this.add(panel3);
this.pack();
this.setSize(600,600);
}

public void actionPerformed(ActionEvent event)
{

JButton mybutton = (JButton)event.getSource();
if (mybutton == clear)
{
textf1.setText("");
textf2.setText("");
textf3.setText("");
textf4.setText("");
textf5.setText("");

}
else if(mybutton == exitBtton)
{
System.exit(0);
}
else if(mybutton == save)
{

}
else if(mybutton == viewInfoEntered)
{

aFrame = new JFrame();
JButton exitButton = new JButton("Exit");

ImageIcon idIcon = new ImageIcon("D:\\Picture2.png");
JButton idButtonn = new JButton(idIcon);
idButtonn.setBackground(Color.BLUE);
idButtonn.setBorderPainted(false);


JPanel myPanel = new JPanel ();
JPanel wholePanel = new JPanel ();
myPanel.setLayout(new BorderLayout(5,5));
JLabel wholeLabel = new JLabel("INFORMATION ENTERED");
addItem(wholePanel,wholeLabel, 0,0, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(wholePanel,idButtonn, 0,1, 0, 0,GridBagConstraints.WEST,GridBagConstraints.NONE);

aFrame.setTitle("UNIMA LIBRARY SYSTEM");

JTextArea myArea = new JTextArea(12,20);
myArea.setText("AUTHOR/S:\t\t"+textf1.getText()+"\n\n");
myArea.append("SERIAL NUMBER:\t"+textf2.getText()+"\n\n");
myArea.append("BOOK TITLE:\t\t"+textf3.getText()+"\n\n");
myArea.append("PUBLISHER:\t\t"+textf4.getText()+"\n\n");
myArea.append("DATE OF ARRIVAL:\t"+textf5.getText()+"\n\n");
myArea.setEditable(true);
myArea.setFont(new Font("algerian",Font.BOLD,16));

myPanel.add(myArea,BorderLayout.CENTER);
myPanel.add(wholePanel,BorderLayout.NORTH);
myPanel.add(exitButton,BorderLayout.SOUTH);
wholePanel.setBackground(Color.BLUE);
myArea.setBackground(Color.WHITE);

aFrame.setContentPane(myPanel);
aFrame.setLocation(700,200);
aFrame.setSize(700,600);
aFrame.setVisible(true);
aFrame.setResizable(true);

wholeLabel.setFont(new Font("Algerian",Font.BOLD,22));


}

else if(mybutton == booking)
{ JButton mybuttonn = (JButton)event.getSource();

bFrame = new JFrame();
bFrame.setTitle("UNIMA LIBRARY SYSTEM");

JPanel myPanel = new JPanel ();
JPanel barPanel = new JPanel ();
JPanel bothPanel=new JPanel();

JLabel barLabel = new JLabel("INFORMATION ENTERED");
barPanel.setLayout(new BorderLayout());
bothPanel.setLayout(new BorderLayout(5,5));
barPanel.add(barLabel,BorderLayout.NORTH);


bothPanel.add(barPanel,BorderLayout.NORTH);
bothPanel.add(myPanel,BorderLayout.CENTER);


myPanel.setLayout(new GridBagLayout());
myPanel.setBackground(Color.WHITE);

bFrame.setContentPane(myPanel);
bFrame.setLocation(700,200);
bFrame.setSize(700,600);
bFrame.setVisible(true);
bFrame.setResizable(true);


item= new JComboBox();
item.addItem("ShortLoan");
item.addItem("LongLoan");
item.setEditable(true);


dur=new JComboBox();
dur.addItem("1Week");
dur.addItem("2Weeks");
dur.addItem("3Weeks");
dur.addItem("4Weeks");
dur.setEditable(true);

due=new JComboBox();
due.addItem("1Week");
due.addItem("2Weeks");
due.addItem("3Weeks");
due.addItem("4Weeks");
due.setEditable(true);

progCo=new JComboBox();
progCo.addItem("MSE");
progCo.addItem("BIT");
progCo.addItem("BAC");
progCo.addItem("TED");
progCo.setEditable(true);

yearCo=new JComboBox();
yearCo.addItem("one");
yearCo.addItem("two");
yearCo.addItem("three");
yearCo.addItem("four");
yearCo.setEditable(true);

JLabel nameOfStud = new JLabel("Name of Student");
JLabel regNo = new JLabel("Registration No.");
JLabel prog = new JLabel("Program");
JLabel yearr = new JLabel("Year");
JLabel dayOfBook = new JLabel("Borrow Duration");
JLabel typeOfBook = new JLabel("Type of Booking");
JLabel duration = new JLabel("Duration");
JLabel submit = new JLabel("Submission Date");
JLabel terms = new JLabel("Terms and Conditions");
JLabel term1 = new JLabel("Late Submission:Fine of Mk100/day");
JLabel term2 = new JLabel("Lost Book:Buy new one and replace");


dayOfBook.setFont(new Font("Algerian",Font.BOLD,22));
typeOfBook.setFont(new Font("Algerian",Font.BOLD,22));
duration.setFont(new Font("Algerian",Font.BOLD,22));
submit.setFont(new Font("Algerian",Font.BOLD,22));
terms.setFont(new Font("Algerian",Font.BOLD,22));
prog.setFont(new Font("Algerian",Font.BOLD,22));
nameOfStud.setFont(new Font("Algerian",Font.BOLD,22));
regNo.setFont(new Font("Algerian",Font.BOLD,22));
yearr.setFont(new Font("Algerian",Font.BOLD,22));




addItem(myPanel,nameOfStud, 0, 0, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf6, 1, 0, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,regNo, 0, 1, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf7, 1, 1, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,prog, 0, 2, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,progCo, 1, 2, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,yearr, 0,3, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,yearCo, 1,3, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,dayOfBook, 0,4, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,dur, 1,4, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,typeOfBook, 0,5, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,item, 1,5, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,submit, 0,6, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,due, 1,6, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,terms, 0,13, 3, 3,GridBagConstraints.CENTER,GridBagConstraints.NONE);
addItem(myPanel,term1, 0,18, 3, 3,GridBagConstraints.CENTER,GridBagConstraints.NONE);
addItem(myPanel,term2, 0,25, 5, 5,GridBagConstraints.SOUTH,GridBagConstraints.NONE);
addItem(myPanel,BviewInfoEntered, 0, 30, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,Bsave, 1, 30, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,Bclear, 0, 34, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,Bexit, 1, 34, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
}


else if(mybutton == back)
{

cFrame = new JFrame();
JPanel myPanel = new JPanel ();
myPanel.setLayout(new GridBagLayout());
myPanel.setBackground(Color.WHITE);


cFrame.setTitle("UNIMA LIBRARY SYSTEM");
cFrame.setContentPane(myPanel);
cFrame.setLocation(700,200);
cFrame.setSize(500,400);
cFrame.setVisible(true);
cFrame.setResizable(true);

backCo=new JComboBox();
backCo.addItem("Yes");
backCo.addItem("No");
backCo.setEditable(true);

dalCo=new JComboBox();
dalCo.addItem("2days");
dalCo.addItem("3days");
dalCo.addItem("4days");
dalCo.addItem("5days");
dalCo.addItem("6days");
dalCo.addItem("Week");
dalCo.addItem("2Weeks");

dalCo.setEditable(true);


JLabel nameOfStud2 = new JLabel("Name of Student");
JLabel regNo2 = new JLabel("Student Registration No.");
JLabel back1 = new JLabel("Return On Time");
JLabel dalLab = new JLabel("Duration Delayed");


nameOfStud2.setFont(new Font("Algerian",Font.BOLD,15));
regNo2.setFont(new Font("Algerian",Font.BOLD,15));
back1.setFont(new Font("Algerian",Font.BOLD,15));
dalLab.setFont(new Font("Algerian",Font.BOLD,15));


JTextField textf10 = new JTextField(15);
JTextField textf11 = new JTextField(15);

addItem(myPanel,nameOfStud2, 0, 0, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf10, 1,0 , 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,regNo2, 0, 1, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,textf11, 1, 1, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,back1, 0, 2, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,backCo, 1, 2, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,dalLab, 0, 3, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);
addItem(myPanel,dalCo, 1, 3, 1, 1,GridBagConstraints.WEST,GridBagConstraints.NONE);
addItem(myPanel,Cclear, 0, 4, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,Ccal, 1, 4, 1, 1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
addItem(myPanel,Cexit, 0, 5, 1, 1,GridBagConstraints.EAST,GridBagConstraints.NONE);

}

else if(mybutton == BviewInfoEntered)
{

aFrame = new JFrame();

ImageIcon idIcon = new ImageIcon("D:\\Picture2.png");
JButton idButtonn = new JButton(idIcon);
idButtonn.setBackground(Color.BLUE);
idButtonn.setBorderPainted(false);


JPanel myPanel = new JPanel ();
JPanel wholePanel = new JPanel ();
myPanel.setLayout(new BorderLayout(5,5));
JLabel wholeLabel = new JLabel("INFORMATION ENTERED");
addItem(wholePanel,wholeLabel, 0,0, 1, 1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL);
addItem(wholePanel,idButtonn, 0,1, 0, 0,GridBagConstraints.WEST,GridBagConstraints.NONE);

aFrame.setTitle("UNIMA LIBRARY SYSTEM");
JTextArea myArea = new JTextArea(12,20);

myArea.append("STUDENT NAME:"+textf6.getText()+"\t\t"+"\n\n");


myArea.append("REGISRATION NUMBER:\t"+textf7.getText()+"\n\n");

myArea.append("PROGRAM:\t\t");
myArea.append(fName+"\n\n");

myArea.append("YEAR:\t\t");
myArea.append(eName+"\n\n");

myArea.append("BORROW DURATION:\t");
myArea.append(dName+"\n\n");

myArea.append("TYPE OF BOOKING:\t");
myArea.append(cName+"\n\n");

myArea.append("SUBMISSION DATE:\t");
myArea.append(gName+"\n\n");



myArea.append("\t\t\tTERMS AND CONDITION:\t"+textf5.getText()+"\n\n");
myArea.append("\t\tLATE SUBMISSION: FINE OF MK100/DAY\t"+textf5.getText()+"\n\n");
myArea.append("\t\tLOST BOOK: BUY NEW ONE AND REPLACE\t"+textf5.getText()+"\n\n");

myArea.setEditable(true);
myArea.setFont(new Font("algerian",Font.BOLD,16));

myPanel.add(myArea,BorderLayout.CENTER);
myPanel.add(wholePanel,BorderLayout.NORTH);
myPanel.add(exitButton,BorderLayout.SOUTH);
wholePanel.setBackground(Color.BLUE);
myArea.setBackground(Color.WHITE);

aFrame.setContentPane(myPanel);
aFrame.setLocation(700,200);
aFrame.setSize(700,600);
aFrame.setVisible(true);
aFrame.setResizable(true);

wholeLabel.setFont(new Font("Algerian",Font.BOLD,22));


}


else if (mybutton == Cclear)
{ JOptionPane.showMessageDialog(null, "YOUR NAME HAS BEEN CLEARED FROM FILE");
}
else if (mybutton == Ccal)
{ JOptionPane.showMessageDialog(null, "YOUR FINE=MK200");
}
else if(mybutton == Cexit)
{
System.exit(0);
}
else if(mybutton == Bexit)
{
System.exit(0);
}

else if (mybutton == Bclear)
{
textf6.setText("");
textf7.setText("");
}
if(mybutton == exitButton)
{
System.exit(0);
}


}

private static void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align,int space)
{
GridBagConstraints gc = new GridBagConstraints();
gc.gridx = x;
gc.gridy = y;
gc.gridwidth = width;
gc.gridheight = height;
gc.weightx = 100.0;
gc.weighty = 100.0;
gc.insets = new Insets(10, 10, 10, 10);
gc.anchor = align;
gc.fill = space;
p.add(c, gc);
}



public class SaveListener extends MouseAdapter{
public void mouseClicked(MouseEvent evnt){
saving();
}
}

public void saving(){
JFileChooser fileChooser = new JFileChooser();
int result = fileChooser.showSaveDialog(this);
if(result==JFileChooser.APPROVE_OPTION){
File outFile = null;
outFile=fileChooser.getSelectedFile();
if (outFile.exists()){
JOptionPane.showMessageDialog(null, "THE FILE ARLEADY EXISTS");
}
else
try{
FileOutputStream fileStream = new FileOutputStream(outFile);
DataOutputStream dataStream = new DataOutputStream(fileStream);
dataStream.writeUTF(textf1.getText());
dataStream.writeUTF(textf2.getText());
dataStream.writeUTF(textf3.getText());
dataStream.writeUTF(textf4.getText());
dataStream.writeUTF(textf5.getText());

fileStream.close();
}
catch(IOException e){
//JOptionPane.showMessageDialog(null, "Error in Opening");
}

if(result==JFileChooser.ERROR_OPTION){
JOptionPane.showMessageDialog(null, "ERROR OCCURS IN SAVING");
}
}

}

public class CCComboListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
int pos= item.getSelectedIndex();
if(pos==0) cName="ShortLoan";
else if(pos==1) cName="LongLoan";
}
}
public class CCCComboListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
int pos= dur.getSelectedIndex();
if(pos==0) dName="1week";
else if(pos==1) dName="2weeks";
else if(pos==2) dName="3weeks";
else if(pos==3) dName="4weeks";
}
}
public class KomboListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
int pos= yearCo.getSelectedIndex();
if(pos==0) eName="one";
else if(pos==1) eName="two";
else if(pos==2) eName="three";
else if(pos==3) eName="four";

}
}
public class KKomboListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
int pos= progCo.getSelectedIndex();
if(pos==0) fName="MSE";
else if(pos==1) fName="BIT";
else if(pos==2) fName="BAC";
else if(pos==3) fName="TED";
}
}

public class KKKomboListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
int pos= due.getSelectedIndex();
if(pos==0) gName="1week";
else if(pos==1) gName="2week";
else if(pos==2) gName="3weeks";
else if(pos==3) gName="4weeks";
}
}

}