Monday, June 27, 2016

WSO2DAS - Delete all data of a persisted table

Some times when we do analytic work with WSO2 DAS we come across the necessity of clearing data of a specific table instead of deleting whole table and recreating again.

You can use following simple steps to achieve it.
  • Shut down the server if already running.
  • Navigate to [Product_Home]/repository/conf/analytics/analytics-config.xml 
  • Find the child element <analytics-data-purging> under </analytics-dataservice-configuration>.
  • If my table name is FOO_TABLE , provide following attributes
 <analytics-data-purging>
      <purging-enable>true</purging-enable>
      <cron-expression>0 0/1 * * * ?</cron-expression>
      <purge-include-tables>
         <table>FOO_TABLE</table>
      </purge-include-tables>
      <data-retention-days>-1</data-retention-days>
   </analytics-data-purging>

Here cron expression is used to specify a time which the purging going to happen. You can read more about cron expressions using [http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06.html]

After specifying above restart the server and data will be purged corresonding to the cron expression. You need to shutdown the server and make the above to default values so that your data in the table will not be purged again.

Sunday, October 4, 2015

Geo Dashboard - Geo event processing with WSO2 CEP 4.0.0

Complex Event Processing has been a key technology for a business to become a more agile connected business.In a fast changing competitive business model, supporting various business use cases is a huge task. With the release of newer version of WSO2 CEP, capabilities one could expect has grown immensely.  I'll be writing series of blogs regarding the newer and improved features of WSO2 CEP to cater these various use cases. 

Geo Event processing is one of the use cases implemented by leveraging new and improved capabilities of WSO2 CEP 4.0.0. You can download the newly released CEP from the product page[1].  

Said Use case is readily available for you to try out with step by steps[2]. In the sample once the producer runs you will see the real time spatial objects renders on the Jaggery application.I will explain how the inner functionalities are implemented and how they can be further extended easily .

Below shows the simple architecture behind the Geo application. 


To get more knowledge on how these functionalities are been implemented, we can ask our selves three questions.
 1. How and In what ways we can send data to CEP Engine.
 2. How we can identify meaningful events from received data
 3. How these meaningful events can be sent to outside so that we can identify them. 

Following describes three aspects with regards to the Geo Dashboard. So it will be easier for you to understand the terminology better.

Question One.

WSO2 CEP has many endpoints(Event Receivers) defined so that different sources can send data in different ways.

  • email
  • kafka
  • jms
  • mqtt
  • soap 
  • http etc. 

You can follow [3] to identify available event receivers and there functionalities in detail. Geo Dashboard is using TFL(Transport for London) streams which are provided by two API's . As showed above an Event Producer has been written to call these API's and send them to CEP using HTTP input event receiver. You must be wondering in what format we should send data to receiver.  

By default, event receivers process incoming messages in the XML, JSON, Text, Map (Key-value pairs), and WSO2Event formats. You can select desired format when you create the HTTP event receiver and map the incoming attributes to the stream. I will explained more on the concept of stream in the next question. So what happens in the the written custom producer is , its first call those TFL API's and get the data and creates a JSON object out of it. And send this JSON Object to WSO2 CEP HTTP endpoint. So the already created HTTP Event receiver has the mapping type of JSON which maps these JSON elements to a Stream.


Question Two.

In WSO2 CEP All receiving data is mapped to a Stream. Hence different mapping types as mentioned above. A Stream is a basic data model which has a definition. You can read following[4] which has in depth details of a stream. You can think of it as a object representation of data which those data are manipulated in the stages of processors inside CEP Engine.  

To identify meaningful events we need a way to specify rules for the incoming data. This is where SIDDHIQL language comes into play.Please follow [5] to understand more on SiddhiQL language. Below is a sample event stream definition of a Geo Event Stream.


{
"name": "rawInputStream",
"version": "1.0.0",
"nickName": "",
"description": "",
 "payloadData": [
            {
               "name": "id",
               "type": "STRING"
            },
            {
             "name": "timeStamp",
             "type": "LONG"
            },
            {
              "name": "latitude",
              "type": "DOUBLE"
            },
            {
              "name": "longitude",
              "type": "DOUBLE"
            },
            {
              "name": "type",
              "type": "STRING"
            },
            {
              "name": "speed",
               "type": "FLOAT"
            },
            {
              "name": "heading",
              "type": "FLOAT"
            }
             ]
}

You can think of this as the attributes of a car which is in a specific Geo location. So it has a latitude, longitude , speed etc . Since we have this data, a simple siddhiql query can be written to identify a event such as whether these cars exceeds certain speed limit. Then we can sent this trigger to outside where it shows that this specific car has exceeded the speed. Like wise Geo Dashboard has implemented several functionalities,

  • Speed Alert - User can specify a speed limit and spatial objects(cars) which violates will be notified
  • Proximity Alert - User can specify the radius of the area and then SiddhiQL queries checks whether a certain spatial object has come dangerously close to another. 
  • Within Alert - User can draw a certain area in the map and queries checks whether a spatial object is within that area.
  • Stationary Alert - User can draw a certain area and specify a time so that if a spatial object is within the area and is been the area for specified time, then an alert is generated
  • Congestion Alert - For this one of the TFL API's sends traffic congestion areas. So the user can draw a specific area where he wants to get traffic alerts on. So using SiddhiQL we check whether the incoming traffic areas are within the user drawn area. 
Question Three.

So now we have identified meaningful events using SiddhiQL and want to send them out so that they can be shown to the end user. For this purpose WSO2CEP has implemented many publishers as per the receivers mentioned above. 

  • Cassandra 
  • Http
  • kafka
  • RDBMS
  • sms
  • soap etc.

You can follow[6] to identify range of supported Publishers readily available in WSO2 CEP. Geo Dashboard is using Websocket Local publisher and RDBMS Publisher to send data to client side and persist data. 

In order to present data A web application is implemented using JAGGERY which is a open-source and released under Apache 2.0 and a product of WSO2.[7] It has map of London which renders vehicles and bus stops according to events received from TFL streams as mentioned above. 



Above is a Snapshot of Geo dashboard which showing vehicles(blue traingles) and bus stops (orange markers).  Jaggery application has a websocket connected to the websocket local publisher. So that CEP sent output data is received from client side. Here the leaflet js is used to render the maps and do other Geo related functionalities. 


Saturday, January 7, 2012

GUI application

  I thought of showing you guys a GUI(Graphical User Interface) application which we have done for one of our Course works. Application is about a computer shop which sells laptops and computers. We had to build sufficient interfaces which will help the user to interact with the shop items and let the user to choose what he/she wants and purchase them. We are supposed to make this application user friendly as much as possible and let the user to make their choices efficiently. This done using the techniques that i described in my earlier post...
 
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;


import java.awt.*;
import java.sql.*;
import java.util.Enumeration;


class LUi extends JFrame{

private  JLabel petPic ;
private JLabel lCheck;
private JButton bCheck;
private  JLabel reg ;
private JPanel panel;
private  JTextField TUN ;
private JTextField TPW;
private GridBagConstraints grid;
private JButton btnLogin;
private JButton btnExit;
private JLabel lUN;
private JLabel lPW;
private JFrame jf;
String str1="";
    String str2="";
    long t0,t1;
   
   
LUi(){
petPic=new JLabel();
lCheck=new JLabel("Are you new to ECSE501 Computers?");
bCheck=new JButton("Create Account");
reg=new JLabel();
jf = new JFrame("Login");
panel=new JPanel(new GridBagLayout());
TUN=new JTextField("");
TPW=new JPasswordField("");
grid=new GridBagConstraints();
btnLogin=new JButton("Login");
btnExit=new JButton("Exit");
lUN = new JLabel("Username");
lPW = new JLabel("Password");
Font font = new Font("Times New Roman", Font.BOLD, 15);
        lUN.setForeground(Color.WHITE);
        lUN.setFont(font);
       
        grid.gridy = 7;
        grid.insets = new Insets(3, 13, 58, 3);
        panel.add(reg, grid);
       
        grid.gridy = 2;
        grid.insets = new Insets(3, 3, 15, 3);
        panel.add(lUN, grid);
       
        TUN = new JTextField(20);
        grid.gridx = 1;
        grid.gridy = 2;
        grid.insets = new Insets(3, 3, 15, 3);
        panel.add(TUN, grid);
       
        Font font1 = new Font("Times New Roman", Font.BOLD, 15);
        lPW.setForeground(Color.WHITE);
        lPW.setFont(font1);
        grid.gridx = 0;
        grid.gridy = 3;
        grid.insets = new Insets(3, 3, 5, 3);
        panel.add(lPW, grid);
       
        TPW = new JPasswordField(20);
        grid.gridx = 1;
        grid.gridy = 3;
        grid.insets = new Insets(3, 3, 8, 3);
        panel.add(TPW, grid);
       
        grid.gridx = 1;
        grid.gridy = 4;
        grid.insets = new Insets(15, 2, 10, 50);
        panel.add(btnLogin, grid);
       
        grid.gridx = 1;
        grid.gridy = 4;
        grid.insets = new Insets(15, 150, 10, 0);
        panel.add(btnExit, grid);
       
        Font font2 = new Font("Times New Roman", Font.BOLD, 15);
        lCheck.setForeground(Color.WHITE);
        lCheck.setFont(font2);
        grid.gridx = 1;
        grid.gridy = 7;
        grid.insets = new Insets(3, 3, 15, -12);
        panel.add(lCheck, grid);
         
       
        grid.gridx = 1;
        grid.gridy = 8;
        grid.insets = new Insets(0, 150, 10, 0);
        panel.add(bCheck, grid);
             
        grid.gridx = 1;
        grid.gridy = 0;
        grid.insets = new Insets(3, 3, 3, 70);
        petPic.setIcon(new ImageIcon(getClass().getResource("/images/login.png")));
        panel.add(petPic, grid);




        jf.add(panel);
        jf.setSize(500, 500);
        jf.setVisible(true);
        panel.setBackground(Color.lightGray);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        ButtonHandler handler=new ButtonHandler();
btnLogin.addActionListener(handler);
btnExit.addActionListener(handler);
bCheck.addActionListener(handler);
}

private class ButtonHandler implements ActionListener{

public void actionPerformed(ActionEvent event){
boolean ans=false;
if (event.getSource() == btnExit) {
           System.out.println("Thank You");
           System.exit(0);


       }
if(event.getSource()==btnLogin){
str1=TUN.getText();
str2=TPW.getText();
if(str1.equals("") && !str2.equals("")){

JOptionPane.showMessageDialog(null, "Enter UserName ","ERROR",JOptionPane.ERROR_MESSAGE);
TPW.setText("");

}
else if(str2.equals("") && !str1.equals("")){

JOptionPane.showMessageDialog(null, "Enter PassWord ","ERROR",JOptionPane.ERROR_MESSAGE);
TUN.setText("");
}
else if(str2.equals("") && str1.equals("")){

JOptionPane.showMessageDialog(null, "Enter UserName and PassWord ","ERROR",JOptionPane.ERROR_MESSAGE);
}
else{
Login n1=new Login();
try {
ans=n1.validateUser(str1, str2);
}
catch (SQLException e) {
e.printStackTrace();
}
catch(ClassNotFoundException e){
System.out.println("Class not found!");
}
if(ans==true){
new User().setUser(str1);
panel.setBackground(Color.GREEN);
jf.paintComponents(jf.getGraphics());

t0=System.currentTimeMillis();
do{
t1=System.currentTimeMillis();
}
while (t1-t0<1000);
jf.setVisible(false);
WelcmUi f1=new WelcmUi();
ChooseUi c1=new ChooseUi();
}
else{
panel.setBackground(Color.RED);
JOptionPane.showMessageDialog(null, "Entered Usename/Password is incorrect ","ERROR",JOptionPane.ERROR_MESSAGE);
TUN.setText(" ");
TPW.setText("");
}
}
}
if(event.getSource()==bCheck){
jf.setVisible(false);
RegUi u1=new RegUi();
}
}
}
}


class User{
private static String UserName;
public void setUser(String s1){
UserName=s1;
}
public String getUser(){
return UserName;
}
}


class Login{

public boolean validateUser(String s1,String s2) throws SQLException,ClassNotFoundException{

boolean check=false;
Connection c1=null;
Statement stmt=null;
c1=Jdbc.createConnection();
stmt = c1.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users");
while (rs.next()) {
String x = rs.getString("UserName");
String s = rs.getString("Password");

if(x.equals(s1)){
if(s.equals(s2)){
check=true;
}
}  
}
c1.close();
stmt.close();
return check;
    }
}


class Jdbc{

public static Connection createConnection()throws ClassNotFoundException,SQLException {
Connection con=null;

String url = "jdbc:mysql://localhost:3306/";
String dbName = "regDb";
String driverName = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "";
Class.forName(driverName);
con = DriverManager.getConnection(url+dbName, userName, password);

return con;
}
}


class RegUi extends JFrame{



private JLabel lTopic;
private JLabel lTopic1;
private JLabel lbFName;
private JTextField txtFName;
private JLabel lbLName;
private JTextField txtLName;
private JLabel lEmail;
private JTextField txtEmail;
private JLabel lbUName;
private JTextField txtUName;
private JLabel lPWord;
private JPasswordField txtPWord;
private JButton bSignUp;
private JButton bProceed;
private Container pane;
String str1;
String str2;
String str3;
String str4;
String str5;
boolean ans=false;

RegUi(){



lTopic=new JLabel("Sign Up");
lTopic1=new JLabel("Press Proceed to login with your new Username and Password");
lbFName=new JLabel("First Name:");
txtFName=new JTextField();
lbLName=new JLabel("Last Name:");
txtLName=new JTextField();
lEmail=new JLabel("Your Email:");
txtEmail=new JTextField();
lbUName=new JLabel("User Name:");
txtUName=new JTextField();
lPWord=new JLabel("New Password:");
txtPWord=new JPasswordField();
bSignUp=new JButton("Sign Up");
bProceed=new JButton("Proceed");

pane=getContentPane();
pane.setLayout(null);



lTopic.setBounds(50, 10, 100, 50);
pane.add(lTopic);
lTopic.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 20));
lbFName.setBounds(20, 50, 100, 50);
pane.add(lbFName);
txtFName.setBounds(120, 65, 200, 25);
pane.add(txtFName);
lbLName.setBounds(20, 120, 100, 50);
pane.add(lbLName);
txtLName.setBounds(120, 135, 200, 25);
pane.add(txtLName);
lEmail.setBounds(20, 190, 100, 50);
pane.add(lEmail);
txtEmail.setBounds(120, 205, 200, 25);
pane.add(txtEmail);
lbUName.setBounds(20, 260, 100, 50);
pane.add(lbUName);
txtUName.setBounds(120, 275, 200, 25);
pane.add(txtUName);
lPWord.setBounds(20, 330, 100, 50);
pane.add(lPWord);
txtPWord.setBounds(120, 345, 200, 25);
pane.add(txtPWord);
bSignUp.setBounds(260, 400, 100, 40);
pane.add(bSignUp);
lTopic1.setBounds(20, 450, 500, 50);
pane.add(lTopic1);
bProceed.setBounds(260, 510, 100, 40);
pane.add(bProceed);

RegHandler handler=new RegHandler();
bSignUp.addActionListener(handler);
bProceed.addActionListener(handler);



setSize(500,600);
setTitle("Register");
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

private class RegHandler implements ActionListener{

public void actionPerformed(ActionEvent event){

if(event.getSource()==bSignUp){
str1=txtFName.getText();
str2=txtLName.getText();
str3=txtEmail.getText();
str4=txtUName.getText();
str5=txtPWord.getText();

if(str1.equals("") || str2.equals("")|| str3.equals("")|| str4.equals("")|| str5.equals("") ){

JOptionPane.showMessageDialog(null, "You have to fill all the fields ","ERROR",JOptionPane.ERROR_MESSAGE);
if(!str1.equals("")){
txtFName.setText("");
}
if(!str2.equals("")){
txtLName.setText("");
}
if(!str3.equals("")){
txtEmail.setText("");
}
if(!str4.equals("")){
txtUName.setText("");
}
if(!str5.equals("")){
txtPWord.setText("");
}
}
else{

Register r1=new Register();
try {
ans=r1.checkUser(str4);
} catch (ClassNotFoundException e) {
System.out.println("Class not found!");
} catch (SQLException e) {
e.printStackTrace();
}
if(ans==true){
JOptionPane.showMessageDialog(null, "Someone uses same UserName..Enter a different one ","ERROR",JOptionPane.ERROR_MESSAGE);
txtUName.setText("");
}
else{
r1.createUser(str1, str2, str3, str4, str5);
JOptionPane.showMessageDialog(null, "You have created your account successfully","Success",JOptionPane.INFORMATION_MESSAGE);
}
}
}
if(event.getSource()==bProceed){
setVisible(false);
LUi l1=new LUi();
}
}
}
}


class Register{
Connection c1=null;
Statement stmt=null;
PreparedStatement pst = null;
boolean check=false;

public void createUser(String s1,String s2,String s3,String s4,String s5){

try{
 c1=Jdbc.createConnection();
     stmt = c1.createStatement();

     pst=c1.prepareStatement("INSERT INTO users (FirstName,LastName,Email,UserName,Password) VALUES(?,?,?,?,?)");
     pst.setString(1, s1);
     pst.setString(2, s2);
     pst.setString(3, s3);
     pst.setString(4, s4);
     pst.setString(5, s5);
     pst.executeUpdate();
}
catch(ClassNotFoundException e){
System.out.println("Class not found!");
}
catch (SQLException e) {
System.out.println(e.toString());
}
try {
c1.close();
stmt.close();
pst.close();
} catch (SQLException e) {
System.out.println(e.toString());
}
}

public boolean checkUser(String s1) throws ClassNotFoundException, SQLException{
c1=Jdbc.createConnection();
stmt = c1.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users");
while (rs.next()) {
String x = rs.getString("UserName");
if(x.equals(s1)){
check=true;
}  
   }
return check;
}
}
class WelcmUi{
private JLabel pet;
private JFrame jf;
private JPanel panel;
private GridBagConstraints grid;
private Icon egg;

WelcmUi(){

jf = new JFrame();
panel=new JPanel(new GridBagLayout());
grid=new GridBagConstraints();
pet=new JLabel();

grid.gridy = 2;
        grid.insets = new Insets(3, 3, 5, 3);
        panel.add(pet, grid);
       
        pet.setText("Welcome to ECSE501 Computers");
        pet.setFont(new java.awt.Font("Monotype Corsiva", Font.BOLD, 40));
        egg = new ImageIcon(getClass().getResource("/images/welcomec.png"));
        pet.setIcon(egg);
        panel.setBackground(Color.GREEN);
        pet.setVisible(true);


        JOptionPane.showMessageDialog(null, pet, "Welcome", JOptionPane.INFORMATION_MESSAGE);
    }
}


class ChooseUi extends JFrame{

private JFrame jj;
private JPanel panel;
private GridBagConstraints grid;
private JButton bDesktop;
private ImageIcon cup1;
private JLabel lDesktop;
private ImageIcon cup2;
private JButton bLaptop;
private JLabel lLaptop;

ChooseUi(){

jj= new JFrame("What do you prefer?");
panel = new JPanel(new GridBagLayout());
grid = new GridBagConstraints();
cup1 = new ImageIcon(getClass().getResource("/images/desktop.png"));
bDesktop = new JButton(cup1);
lDesktop = new JLabel("Desktop");
cup2 = new ImageIcon(getClass().getResource("/images/laptop.png"));
bLaptop = new JButton(cup2);
lLaptop = new JLabel("Laptop");

grid.gridx = 0;
        grid.gridy = 0;
        grid.insets = new Insets(3, 0, 3, 3);
        bDesktop.setVisible(true);
        panel.add(bDesktop, grid);
     
        Font font = new Font("Times New Roman", Font.BOLD, 30);
      lDesktop.setForeground(Color.WHITE);
        lDesktop.setFont(font);
        grid.gridx = 0;
        grid.gridy = 2;
        grid.insets = new Insets(20, 0, 20, 5);
        panel.add(lDesktop, grid);
       
        grid.gridx = 1;
        grid.gridy = 0;
        grid.insets = new Insets(3, 50, 3, 3);
        bLaptop.setVisible(true);
        panel.add(bLaptop, grid);
     
       
        Font font1 = new Font("Times New Roman", Font.BOLD, 30);
        lLaptop.setForeground(Color.WHITE);
        lLaptop.setFont(font1);
        grid.gridx = 1;
        grid.gridy = 2;
        grid.insets = new Insets(20, 30, 20, 5);
        panel.add(lLaptop, grid);


        ChooseBtnHandler handler=new ChooseBtnHandler();
bDesktop.addActionListener(handler);
bLaptop.addActionListener(handler);
       
        jj.add(panel);
        jj.setSize(1000, 600);
        jj.setVisible(true);
  &nm< $Rx3B   panel.setBackground(Color.lightGray);
        jj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

private class ChooseBtnHandler implements ActionListener{

public void actionPerformed(ActionEvent event){

if(event.getSource()==bDesktop){
jj.setVisible(false);
DesktopUi d1=new DesktopUi();
d1.pack();
d1.setVisible(true);
d1.setSize(600,485);
}
if(event.getSource()==bLaptop){
jj.setVisible(false);
LapUi l1=new LapUi();
l1.pack();
l1.setVisible(true);
l1.setSize(600,485);
}
}
}
}


class DesktopUi extends JFrame implements ActionListener{


public JButton btnP,btnR,Sub,btnD,btnH,btnV,rem;
public JRadioButton Rb1,Rb2,Rb3,Rb4;
public JRadioButton Rb5,Rb6,Rb7,Rb8;
public JRadioButton Rb9,Rb10,Rb11,Rb12;
public JRadioButton Rb13,Rb14,Rb15,Rb16;
public JRadioButton Rb17,Rb18,Rb19,Rb20;
public JRadioButton Rb21,Rb22,Rb23,Rb24,Rb25;
public ButtonGroup BG1,BG2,BG3,BG4,BG5;
public JLabel l1,l2,l3,l4,l5;
public JLabel pl1,pl2,pl3,pl4,pl5;
public Container con;
public String[] Sary;

public DesktopUi() {
Sary= new String[5];
for(int x=0;x<Sary.length;x++){
          Sary[x]=" ";
}  

this.setVisible(true);
this.setSize(600,400);
con= getContentPane();
con.setLayout(null);

final Box b1= Box.createVerticalBox();
final Box b2= Box.createVerticalBox();
final Box b3= Box.createVerticalBox();
final Box b4= Box.createVerticalBox();
final Box b5= Box.createVerticalBox();
final Box first= Box.createVerticalBox();
final Box buy= Box.createVerticalBox();
final Box choz= Box.createVerticalBox();
con.setBackground(Color.white);

l1= new JLabel();
l2= new JLabel();
l3= new JLabel();
l4= new JLabel();
l5= new JLabel();

first.setVisible(true);
first.setBounds(125, 0, 275, 450);
first.setBorder(BorderFactory.createTitledBorder(" "));
con.add(first);
buy.setVisible(true);
buy.setBounds(400, 0, 200, 450);
buy.setBorder(BorderFactory.createTitledBorder("Selected items"));
con.add(buy);

BG1=new ButtonGroup();
BG2= new ButtonGroup();
BG3= new ButtonGroup();
BG4= new ButtonGroup();
BG5= new ButtonGroup();

String[] priceList1 =new String[25];
int cnt1=0;

GetNewDesktop1 getDesktop1 =new GetNewDesktop1();

try {
priceList1 =getDesktop1.getData();
}
catch (SQLException e2) {
e2.printStackTrace();
}
catch (ClassNotFoundException e1) {
System.out.println("Class not found!");
}

Rb1= new JRadioButton("Intel Dg31pr (1y)");
Rb2= new JRadioButton("Intel Dg35ec (1y)");
Rb3= new JRadioButton("Intel Extreme Dx58so (2y)");
Rb4= new JRadioButton("Intel D945gclf - Atom (2y)");
Rb5= new JRadioButton("Gigabyte Ga31m-E(3y)");

pl1=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl2=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl3=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl4=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl5=new JLabel("Price - Rs. "+ priceList1[cnt1++]);

ImageIcon m1 = new ImageIcon("images\\mb1.jpg");
JLabel Mb1 = new JLabel(" ", m1, JLabel.CENTER);

BG1.add(Rb1);
BG1.add(Rb2);
BG1.add(Rb3);
BG1.add(Rb4);
BG1.add(Rb5);

b1.add(Rb1);
b1.add(pl1);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb2);
b1.add(pl2);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb3);
b1.add(pl3);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb4);
b1.add(pl4);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb5);
b1.add(pl5);
b1.add(Mb1);


Rb1.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb1.getText();
             l2.setText(Sary[0]);
            }}});
Rb2.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb2.getText();
             l2.setText(Sary[0]);
            }}});
Rb3.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb3.getText();
             l2.setText(Sary[0]);
            }}});
Rb4.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb4.getText();
             l2.setText(Sary[0]);
            }}});
Rb5.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb5.getText();
             l2.setText(Sary[0]);
            }}});

b1.setVisible(false);
b1.setBounds(125, 0, 275, 450);
b1.setBorder(BorderFactory.createTitledBorder(" "));
btnP=new JButton(" Motherboard ");
btnP.setMaximumSize(new Dimension(120, 25));



con.add(b1);

btnP.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b1.setVisible(true);
         b2.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         }
   });
//Ram

Rb9= new JRadioButton("512mb (Ddr1) Kvr400 Kingston");
Rb10= new JRadioButton("1gb (Ddr1)Kvr400 Kingston (3y)");
Rb6= new JRadioButton("1gb (Ddr2) Kvr667 Kingston(3y)");
Rb7= new JRadioButton("2gb (Ddr2) Kvr667 Kingston(3y)");
Rb8= new JRadioButton("2gb (Ddr2) Kvr800 Kingston(3y)");

pl1=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl2=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl3=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl4=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl5=new JLabel("Price - Rs. "+ priceList1[cnt1++]);

ImageIcon r2 = new ImageIcon("images\\r2.jpg");
JLabel R2 = new JLabel(" ", r2, JLabel.CENTER);

BG2.add(Rb9);
BG2.add(Rb10);
BG2.add(Rb6);
BG2.add(Rb7);
BG2.add(Rb8);

b2.add( Box.createRigidArea(new Dimension(0,20)));
b2.add(Rb10);
b2.add(pl1);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb9);
b2.add(pl2);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb6);
b2.add(pl3);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb7);
b2.add(pl4);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb8);
b2.add(pl5);
b2.add( Box.createRigidArea(new Dimension(0,10)));
b2.add(R2);

Rb9.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb9.getText();
             l3.setText(Sary[1]);
            }
        });
Rb10.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb10.getText();
             l3.setText(Sary[1]);
            }
        });
Rb6.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb6.getText();
             l3.setText(Sary[1]);
            }
        });
Rb7.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb7.getText();
             l3.setText(Sary[1]);
            }
        });
Rb8.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb8.getText();
             l3.setText(Sary[1]);
            }
});

b2.setVisible(false);
b2.setBounds(125, 0, 275, 450);
b2.setBorder(BorderFactory.createTitledBorder(" "));
btnR=new JButton("RAM");
btnR.setMaximumSize(new Dimension(120, 25));
con.add(b2);

btnR.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b2.setVisible(true);  
         b1.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
       
         }
});
//Hard
Rb15= new JRadioButton("Seagate 80 Gb Ide");
Rb11= new JRadioButton("Maxtor 160 Gb Ide");
Rb12= new JRadioButton("Hitachi 320gb Sata");
Rb13= new JRadioButton("Hitachi 500gb Sata");
Rb14= new JRadioButton("Samsung 160gb Sata-li");

pl1=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl2=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl3=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl4=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl5=new JLabel("Price - Rs. "+ priceList1[cnt1++]);

ImageIcon H1 = new ImageIcon("images\\dh1.jpg");
JLabel hr1 = new JLabel(" ", H1, JLabel.CENTER);

BG3.add(Rb15);
BG3.add(Rb11);
BG3.add(Rb12);
BG3.add(Rb13);
BG3.add(Rb14);

b3.add( Box.createRigidArea(new Dimension(0,20)));
b3.add(Rb15);
b3.add(pl1);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb11);
b3.add(pl2);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb12);
b3.add(pl3);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb13);
b3.add(pl4);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb14);
b3.add(pl5);
b3.add(hr1);

Rb15.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb15.getText();
             l4.setText(Sary[2]);
            }
        });
Rb11.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb11.getText();
             l4.setText(Sary[2]);
            }
        });
Rb12.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb12.getText();
             l4.setText(Sary[2]);
            }
        });
Rb13.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb13.getText();
             l4.setText(Sary[2]);
            }
        });
Rb14.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb14.getText();
             l4.setText(Sary[2]);
            }
        });

b3.setVisible(false);
b3.setBounds(125, 0, 275, 450);
b3.setBorder(BorderFactory.createTitledBorder(" "));
btnH=new JButton("HDD");
btnH.setMaximumSize(new Dimension(120, 25));
con.add(b3);

btnH.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b3.setVisible(true);  
         b1.setVisible(false);
         b2.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
       
         }
   });
//Disply

final Box hb1= Box.createHorizontalBox();
final Box hb2= Box.createHorizontalBox();
final Box hb3= Box.createHorizontalBox();
final Box hb4= Box.createHorizontalBox();
final Box hb5= Box.createHorizontalBox();
final Box hb11= Box.createHorizontalBox();
final Box hb12= Box.createHorizontalBox();

Rb19= new JRadioButton("Megabox 17 Lcd");
Rb20= new JRadioButton("Samsung 19''lcd");
Rb16= new JRadioButton("Aoc 15.6 Lcd");
Rb17= new JRadioButton("Aoc 17'' Lcd 177sa");
Rb18= new JRadioButton("Lenovo 18.5\"2580-Ab1");

pl1=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl2=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl3=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl4=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl5=new JLabel("Price - Rs. "+ priceList1[cnt1++]);


Rb19.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb19.getText();
             l5.setText(Sary[3]);
            }
        });
Rb20.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb20.getText();
             l5.setText(Sary[3]);
            }
        });
Rb16.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb16.getText();
             l5.setText(Sary[3]);
            }
        });
Rb17.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb17.getText();
             l5.setText(Sary[3]);
            }
        });
Rb18.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb18.getText();
             l5.setText(Sary[3]);
            }
        });

ImageIcon d1 = new ImageIcon("images\\D1.jpg");
JLabel D1 = new JLabel(" ", d1, JLabel.CENTER);

ImageIcon d2 = new ImageIcon("images\\D2.jpg");
JLabel D2 = new JLabel(" ", d2, JLabel.CENTER);

ImageIcon d3 = new ImageIcon("images\\D3.jpg");
JLabel D3 = new JLabel(" ", d3, JLabel.CENTER);

ImageIcon d4 = new ImageIcon("images\\D4.jpg");
JLabel D4 = new JLabel(" ", d4, JLabel.CENTER);

ImageIcon d5 = new ImageIcon("images\\D5.jpg");
JLabel D5 = new JLabel(" ", d5, JLabel.CENTER);

BG4.add(Rb19);
BG4.add(Rb20);
BG4.add(Rb16);
BG4.add(Rb17);
BG4.add(Rb18);

hb1.add(D1);
hb1.add( Box.createRigidArea(new Dimension(20,00)));
hb1.add(D2);
hb2.add(Rb19);
hb2.add(Rb20);
hb11.add(pl1);
hb11.add( Box.createRigidArea(new Dimension(10,0)));
hb11.add(pl2);
b4.add(hb1);
b4.add(hb2);
b4.add(hb11);

hb3.add(D3);
hb3.add( Box.createRigidArea(new Dimension(20,00)));
hb3.add(D4);
hb12.add(pl3);
hb12.add( Box.createRigidArea(new Dimension(10,0)));
hb12.add(pl4);
hb4.add(Rb16);
hb4.add(Rb17);
b4.add(hb3);
b4.add(hb4);
b4.add(hb12);

b4.add(D5);
hb5.add(Rb18);
b4.add(hb5);
b4.add(pl5);

b4.setVisible(false);
b4.setBounds(125, 0, 275, 450);
b4.setBorder(BorderFactory.createTitledBorder(" "));
btnV=new JButton("Monitor");
btnV.setMaximumSize(new Dimension(120, 25));
con.add(b4);

btnV.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b4.setVisible(true);  
         b1.setVisible(false);
         b3.setVisible(false);
         b2.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
       
         }
   });

Rb21= new JRadioButton("Msi 1gb N9500gt-Md Ddr2 (1y)");
Rb22= new JRadioButton("Asus 1gb Engt220 (1y)");
Rb23= new JRadioButton("Msi 1gb Vn240gt-Md (1y)");
Rb24= new JRadioButton("Msi 512mb Vn210gs-Md (1y)");
Rb25= new JRadioButton("Foxconn 512mb 9400gt Pci(1y)");

pl1=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl2=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl3=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl4=new JLabel("Price - Rs. "+ priceList1[cnt1++]);
pl5=new JLabel("Price - Rs. "+ priceList1[cnt1++]);

ImageIcon v1 = new ImageIcon("images\\V1.jpg");
JLabel VGA1 = new JLabel(" ", v1, JLabel.CENTER);

BG5.add(Rb21);
BG5.add(Rb22);
BG5.add(Rb23);
BG5.add(Rb24);
BG5.add(Rb25);

b5.add(Rb21);
b5.add(pl1);
b5.add( Box.createRigidArea(new Dimension(0,8)));
b5.add(Rb22);
b5.add(pl2);
b5.add( Box.createRigidArea(new Dimension(0,8)));
b5.add(Rb23);
b5.add(pl3);
b5.add( Box.createRigidArea(new Dimension(0,8)));
b5.add(Rb24);
b5.add(pl4);
b5.add( Box.createRigidArea(new Dimension(0,8)));
b5.add(Rb25);
b5.add(pl5);
b5.add(VGA1);

Rb21.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb21.getText();
             l1.setText(Sary[4]);
            }
        });
Rb22.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb22.getText();
             l1.setText(Sary[4]);
            }
        });
Rb23.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb23.getText();
             l1.setText(Sary[4]);
            }
        });
Rb24.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb24.getText();
             l1.setText(Sary[4]);
            }
        });
Rb25.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb25.getText();
             l1.setText(Sary[4]);
            }
        });

b5.setVisible(false);
b5.setBounds(125, 0, 275, 450);
b5.setBorder(BorderFactory.createTitledBorder(" "));
btnD=new JButton("VGA");
btnD.setMaximumSize(new Dimension(120, 25));
con.add(b5);

btnD.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b5.setVisible(true);  
         b1.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b2.setVisible(false);
         first.setVisible(false);
         }
   });

buy.add(l1);
buy.add(l2);
buy.add(l3);
buy.add(l4);
buy.add(l5);

//Submit
Sub = new JButton(" SUBMIT ");
Sub.setMaximumSize(new Dimension(120, 25));
Sub.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
       
                  setVisible(false);
                  ProductsSelection1 PS1 =new ProductsSelection1();
                  try {
                PS1.getPrice(Sary);
                  }
                  catch (ClassNotFoundException e1) {
                 System.out.println("Class not found!");
                  }
                  catch (SQLException e1) {
e1.printStackTrace();
                  }
         }
   });

buy.add( Box.createRigidArea(new Dimension(0,50)));
ImageIcon image = new ImageIcon("images\\1.jpg");
JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
buy.add(label1);

buy.add(Sub);

//remove
rem = new JButton(" Remove ");
rem.setMaximumSize(new Dimension(120, 25));
rem.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         for(int x=0;x<Sary.length;x++)
                 Sary[x]=" ";
       
         l1.setText(" ");
         l2.setText(" ");
         l3.setText(" ");
         l4.setText(" ");
         l5.setText(" ");
                 
         }
   });

buy.add(rem);
choz.add( Box.createRigidArea(new Dimension(0,50)));
choz.add(btnD);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnP);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnR);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnH);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnV);

choz.setBorder(BorderFactory.createTitledBorder("Choose "));
choz.setBounds(0, 0, 125, 450);
con.add(choz);
}
public void back(String[] ar){
 
for(int x=0;x<5;x++){
    Sary[x]= ar[x];
   }
   l2.setText(Sary[0]);
        l3.setText(Sary[1]);
        l4.setText(Sary[2]);
        l5.setText(Sary[3]);
        l1.setText(Sary[4]);
    }
public void actionPerformed(ActionEvent e) {


}


}


class GetNewDesktop1 {

public String[] getData() throws SQLException, ClassNotFoundException{

String[] priceList1 =new String[25];
Connection connection1 =null;
Statement stmt1 =null;
int count =0;

connection1   =Jdbc.createConnection();
stmt1 =connection1.createStatement();
ResultSet result1 =stmt1.executeQuery("SELECT * FROM motherboard");
while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM ramdesktop");

while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM harddrivedesktop");

while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM displaydesktop");

while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM vga");

while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
connection1.close();
stmt1.close();

for(int cnt1=0;cnt1<25;cnt1++)
{
System.out.println(priceList1[cnt1]);
}
return priceList1;

}

public static void main(String[] args)
{

GetNew1 getNew1 =new GetNew1();

String[] price1 =new String[25];

try {
price1 =getNew1.getData();
}
catch (SQLException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e1) {
System.out.println("Class not found!");
}
for(int cnt1=0;cnt1<25;cnt1++)
{
System.out.println(price1[cnt1]);
}


}
}
class ProductsSelection1 {

public void getPrice(String[] products) throws SQLException, ClassNotFoundException
{

int count =0;
double[] priceProduct1 =new double[5];
Connection connection1 =null;
Statement stmt1 =null;
String name1;
double price1;
int cnt1 =0;
try
{
connection1   =Jdbc.createConnection();
stmt1 =connection1.createStatement();
ResultSet result1 =stmt1.executeQuery("SELECT * FROM motherboard");

if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");
if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}

}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM ramdesktop");
if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");
if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}
}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM harddrivedesktop");
if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");

if(name1.equals(products[cnt1]))
{

priceProduct1[count++] =price1;
}
}

}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM displaydesktop");
if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");

if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}
}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM vga");
if(products[cnt1].equals(" "))
{

priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");
if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}
}
cnt1++;
}
catch(SQLException e)
{
System.out.println(e.toString());
}
finally
{
connection1.close();
stmt1.close();
}
SubmitGui sub1 =new SubmitGui(2,products,priceProduct1);
}
}

class SubmitGui extends JFrame{


public JLabel Hed;
public JLabel DATA1;
public JLabel DATA2;
public JLabel DATA3;
public JLabel DATA4;
public JLabel DATA5;
public JLabel total;
public JLabel pri1;
public JLabel pri2;
public JLabel pri3;
public JLabel pri4;
public JLabel pri5;
public JLabel Tpri;
public JLabel Suc;

public JButton btnOk,btnback;
private Container pane1;
public JFrame f1;

private String[] ar,pr;
private Boolean[] cheqArry;
private double totalPrize=0;
int choiz;

public SubmitGui(int no,String[] arry,double[] prize) {
pr= new String[5];
cheqArry= new Boolean[5];
choiz=no;
ar=arry;
int cnt=0,cnt2=0;
pane1 =getContentPane();
pane1.setLayout(null);
for(int x=0;x<prize.length;x++){
totalPrize+=prize[x];
}
Font font = new Font("Calibri (Body)", Font.BOLD, 15);
Hed= new JLabel("These are the parts you bought ");
Hed.setFont(font);
Hed.setForeground(Color.darkGray);
Hed.setBounds(75, 25, 300, 50);
pane1.add(Hed);
btnOk= new JButton("purchase");
btnOk.setBounds(125, 300, 100, 25);
btnback= new JButton("Back");
btnback.setBounds(125, 325, 100, 25);
pane1.setBackground(Color.black);

for(int z=0;z<prize.length;z++){
if(prize[z]==0.0){
pr[z]="";
cheqArry[z]=false;
}
else{
pr[z]="Rs."+Double.toString(prize[z]);
cheqArry[z]=true;
}
}
DATA1= new JLabel(ar[cnt++]);
DATA2= new JLabel(ar[cnt++]);
DATA3= new JLabel(ar[cnt++]);
DATA4= new JLabel(ar[cnt++]);
DATA5= new JLabel(ar[cnt++]);
total= new JLabel("Total Price");
total.setForeground(Color.red);
pri1= new JLabel(pr[cnt2++]);
pri2= new JLabel(pr[cnt2++]);
pri3= new JLabel(pr[cnt2++]);
pri4= new JLabel(pr[cnt2++]);
pri5= new JLabel(pr[cnt2++]);

Tpri= new JLabel("Rs."+Double.toString(totalPrize));
Tpri.setForeground(Color.red);

int y=75;

total.setBounds(50, 250, 150, 25);
Tpri.setBounds(250, 250, 100, 25);


DATA1.setForeground(Color.white);
DATA2.setForeground(Color.white);
DATA3.setForeground(Color.white);
DATA4.setForeground(Color.white);
DATA5.setForeground(Color.white);

pri1.setForeground(Color.white);
pri2.setForeground(Color.white);
pri3.setForeground(Color.white);
pri4.setForeground(Color.white);
pri5.setForeground(Color.white);

if(cheqArry[0]==true){
DATA1.setBounds(50, y=y+25, 150, 25);
pri1.setBounds(250, y, 100, 25);
pane1.add(DATA1);
pane1.add(pri1);
}
if(cheqArry[1]==true){
DATA2.setBounds(50, y=y+25, 150, 25);
pri2.setBounds(250, y, 100, 25);
pane1.add(DATA2);
pane1.add(pri2);
}
if(cheqArry[2]==true){
DATA3.setBounds(50, y=y+25, 150, 25);
pri3.setBounds(250, y, 100, 25);
pane1.add(DATA3);
pane1.add(pri3);
}
if(cheqArry[3]==true){
DATA4.setBounds(50, y=y+25, 150, 25);
pri4.setBounds(250, y, 100, 25);
pane1.add(DATA4);
pane1.add(pri4);
}
if(cheqArry[4]==true){
DATA5.setBounds(50, y=y+25, 150, 25);
pri5.setBounds(250, y, 100, 25);
pane1.add(DATA5);
pane1.add(pri5);
}

pane1.add(total);
pane1.add(Tpri);
pane1.add(btnOk);
pane1.add(btnback);

btnOk.addActionListener( new ActionListener() {          
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btnOk){

try {
if(choiz==1){
purAddLapDB db=new purAddLapDB();
db.sql(ar,totalPrize);
}
else
{
purAddDeskDB db=new purAddDeskDB();
db.sql(ar,totalPrize);
}
JOptionPane.showMessageDialog(f1, "Your request is successfully sent");
}
catch (InstantiationException e1) {
e1.printStackTrace();
}
catch (IllegalAccessException e1) {
e1.printStackTrace();
}
catch (ClassNotFoundException e2) {
System.out.println("Class not found!");
}
}
}
});
btnback.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            if(e.getSource()==btnback){
              if(choiz==1){
              setVisible(false);
              LapUi l= new LapUi();
              l.back(ar);
            l.pack();
            l.setVisible(true);
            l.setSize(600,435);
              }
              else{
              setVisible(false);
              DesktopUi l= new DesktopUi();
              l.back(ar);
              l.pack();
              l.setVisible(true);
              l.setSize(600,435);
           
              }
             
               }
            }
});
this.setBackground(Color.LIGHT_GRAY);
setSize(400,450);
setTitle("select2");
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}


class purAddDeskDB {
static int purNum=2;
    public void sql(String[]ar,double total){
        try{
        Connection co=Jdbc.createConnection();    
        Statement stm =co.createStatement();
        String s1 = "SELECT PurNo  from  AddDBDesk ";
       
        ResultSet rs = stm.executeQuery(s1);
        int no = 0;
        while (rs.next()) {
               no= Integer.parseInt( rs.getString("PurNo"));
        }
       
        PreparedStatement pstmt = co.prepareStatement("INSERT INTO AddDBDesk " +"VALUES (?,?, ?, ?, ?, ?, ?, ?)");
       
        String str=new User().getUser();
        pstmt.setInt(1, ++no);
        pstmt.setString(2, str);
        for(int x=0,y=3;x!=5;x++,y++){
        pstmt.setString(y, ar[x]);
        }
        pstmt.setDouble(8, total);
        pstmt.executeUpdate();
        }
        catch (ClassNotFoundException e) {
System.out.println("Class not found!");
}
        catch(SQLException e){
        System.out.println(e.toString());
        }
   }
}


class LapUi extends JFrame implements ActionListener{


public JButton btnP,btnR,Sub,btnD,btnH,btnV,rem;
public JRadioButton Rb1,Rb2,Rb3,Rb4,ans,Rb10;
public JRadioButton Rb5,Rb6,Rb7,Rb8,Rb9;
public JRadioButton Rb11,Rb12,Rb13,Rb14,Rb15;
public JRadioButton Rb20,Rb16,Rb17,Rb18,Rb19;
public JRadioButton Rb25,Rb21,Rb22,Rb23,Rb24;
public JLabel pl1,pl2,pl3,pl4,pl5;
public ButtonGroup BG1,BG2,BG3,BG4,BG5;
public JLabel l1,l2,l3,l4,l5;
public Container con;
public String[] Sary;

public LapUi() {

Sary= new String[5];
for(int x=0;x<Sary.length;x++){
       Sary[x]=" ";
}
this.setVisible(true);
this.setSize(600,435);
con= getContentPane();
con.setLayout(null);

final Box b1= Box.createVerticalBox();
final Box b2= Box.createVerticalBox();
final Box b3= Box.createVerticalBox();
final Box b4= Box.createVerticalBox();
final Box b5= Box.createVerticalBox();
final Box first= Box.createVerticalBox();
final Box buy= Box.createVerticalBox();
final Box choz= Box.createVerticalBox();
con.setBackground(Color.white);

l1= new JLabel("");
l2= new JLabel("");
l3= new JLabel("");
l4= new JLabel("");
l5= new JLabel("");

first.setVisible(true);
first.setBounds(125, 0, 275, 450);
first.setBorder(BorderFactory.createTitledBorder(" "));
con.add(first);
buy.setVisible(true);
buy.setBounds(400, 0, 200, 450);
buy.setBorder(BorderFactory.createTitledBorder("Selected items"));
con.add(buy);

BG1= new ButtonGroup();
BG2= new ButtonGroup();
BG3= new ButtonGroup();
BG4= new ButtonGroup();
BG5= new ButtonGroup();

String[] priceList1 =new String[25];
int count=0;

GetNew1 getNew1 = new GetNew1();

try {
priceList1 =getNew1.getData();
}
catch (ClassNotFoundException e1) {
System.out.println("Class not found!");
}
catch (SQLException e2) {
e2.printStackTrace();
}

Rb1= new JRadioButton("Core i3 2.10Ghz(2310M)");
Rb2= new JRadioButton("Core i5 2.30Ghz(2410M)");
Rb3= new JRadioButton("Core i5 2.40Ghz(2430M)");
Rb4= new JRadioButton("Core i7 2.0Ghz(QM2630)");
Rb5= new JRadioButton("Core-i7 2.2Ghz(QM2670)");

pl1=new JLabel("Price - Rs. "+ priceList1[count++]);
pl2=new JLabel("Price - Rs. "+ priceList1[count++]);
pl3=new JLabel("Price - Rs. "+ priceList1[count++]);
pl4=new JLabel("Price - Rs. "+ priceList1[count++]);
pl5=new JLabel("Price - Rs. "+ priceList1[count++]);

ImageIcon p1 = new ImageIcon("images\\p1.jpg");
JLabel Lp1 = new JLabel(" ", p1, JLabel.CENTER);

BG1.add(Rb1);
BG1.add(Rb2);
BG1.add(Rb3);
BG1.add(Rb4);
BG1.add(Rb5);

b1.add( Box.createRigidArea(new Dimension(0,10)));
b1.add(Rb1);
b1.add(pl1);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb2);
b1.add(pl2);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb3);
b1.add(pl3);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb4);
b1.add(pl4);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb5);
b1.add(pl5);
b1.add(Lp1);

Rb1.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[0]= Rb1.getText();
             l2.setText(Sary[0]);
            }
        });
Rb2.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[0]= Rb2.getText();
             l2.setText(Sary[0]);
            }
        });
Rb3.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[0]= Rb3.getText();
             l2.setText(Sary[0]);
            }
        });
Rb4.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[0]= Rb4.getText();
             l2.setText(Sary[0]);
            }
        });
Rb5.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[0]= Rb5.getText();
             l2.setText(Sary[0]);
            }
        });

b1.setVisible(false);
b1.setBounds(125, 0, 275, 450);
b1.setBorder(BorderFactory.createTitledBorder(" "));
btnP=new JButton(" Processors ");
btnP.setMaximumSize(new Dimension(120, 25));

con.add(b1);

btnP.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b1.setVisible(true);
         b2.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         }
   });
//Ram

Rb10= new JRadioButton("1GB DDR3");
Rb9= new JRadioButton("2GB DDR3");
Rb6= new JRadioButton("4GB DDR3");
Rb7= new JRadioButton("6GB DDR3");
Rb8= new JRadioButton("8GB DDR3");

pl1=new JLabel("Price - Rs. "+ priceList1[count++]);
pl2=new JLabel("Price - Rs. "+ priceList1[count++]);
pl3=new JLabel("Price - Rs. "+ priceList1[count++]);
pl4=new JLabel("Price - Rs. "+ priceList1[count++]);
pl5=new JLabel("Price - Rs. "+ priceList1[count++]);

ImageIcon r1 = new ImageIcon("images\\R1.jpg");
JLabel R1 = new JLabel(" ", r1, JLabel.CENTER);

BG2.add(Rb10);
BG2.add(Rb9);
BG2.add(Rb6);
BG2.add(Rb7);
BG2.add(Rb8);

b2.add( Box.createRigidArea(new Dimension(0,20)));
b2.add(Rb10);
b2.add(pl1);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb9);
b2.add(pl2);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb6);
b2.add(pl3);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb7);
b2.add(pl4);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb8);
b2.add(pl5);
b2.add( Box.createRigidArea(new Dimension(0,10)));
b2.add(R1);

Rb9.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb9.getText();
             l3.setText(Sary[1]);
            }
        });
Rb10.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb10.getText();
             l3.setText(Sary[1]);
            }
        });
Rb6.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb6.getText();
             l3.setText(Sary[1]);
            }
        });
Rb7.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb7.getText();
             l3.setText(Sary[1]);
            }
        });
Rb8.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[1]= Rb8.getText();
             l3.setText(Sary[1]);
            }
        });

b2.setVisible(false);
b2.setBounds(125, 0, 275, 450);
b2.setBorder(BorderFactory.createTitledBorder(" "));
btnR=new JButton("RAM");
btnR.setMaximumSize(new Dimension(120, 25));
con.add(b2);

btnR.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b2.setVisible(true);  
         b1.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
       
         }
   });
//Hard

Rb11= new JRadioButton("250GB");
Rb12= new JRadioButton("320GB");
Rb13= new JRadioButton("500GB");
Rb14= new JRadioButton("640GB");
Rb15= new JRadioButton("750GB");

pl1=new JLabel("Price - Rs. "+ priceList1[count++]);
pl2=new JLabel("Price - Rs. "+ priceList1[count++]);
pl3=new JLabel("Price - Rs. "+ priceList1[count++]);
pl4=new JLabel("Price - Rs. "+ priceList1[count++]);
pl5=new JLabel("Price - Rs. "+ priceList1[count++]);

ImageIcon h1 = new ImageIcon("images\\Lh1.jpg");
JLabel hd1 = new JLabel(" ", h1, JLabel.CENTER);

BG3.add(Rb15);
BG3.add(Rb11);
BG3.add(Rb12);
BG3.add(Rb13);
BG3.add(Rb14);

b3.add( Box.createRigidArea(new Dimension(0,20)));
b3.add(Rb15);
b3.add(pl1);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb11);
b3.add(pl2);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb12);
b3.add(pl3);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb13);
b3.add(pl4);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb14);
b3.add(pl5);
b3.add(hd1);

Rb15.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb15.getText();
             l4.setText(Sary[2]);
            }
        });
Rb11.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb11.getText();
             l4.setText(Sary[2]);
            }
        });
Rb12.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb12.getText();
             l4.setText(Sary[2]);
            }
        });
Rb13.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb13.getText();
             l4.setText(Sary[2]);
            }
        });
Rb14.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[2]= Rb14.getText();
             l4.setText(Sary[2]);
            }
        });

b3.setVisible(false);
b3.setBounds(125, 0, 275, 450);
b3.setBorder(BorderFactory.createTitledBorder(" "));
btnH=new JButton("HDD");
btnH.setMaximumSize(new Dimension(120, 25));
con.add(b3);

btnH.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b3.setVisible(true);  
         b1.setVisible(false);
         b2.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
       
         }
   });
//Disply

Rb20= new JRadioButton("14\" WXGA");
Rb19= new JRadioButton("14.1\" wxga");
Rb16= new JRadioButton("15\" XGA ");
Rb17= new JRadioButton("15.4\"WXGA");
Rb18= new JRadioButton("17\"WUXGA");

pl1=new JLabel("Price - Rs. "+ priceList1[count++]);
pl2=new JLabel("Price - Rs. "+ priceList1[count++]);
pl3=new JLabel("Price - Rs. "+ priceList1[count++]);
pl4=new JLabel("Price - Rs. "+ priceList1[count++]);
pl5=new JLabel("Price - Rs. "+ priceList1[count++]);


Rb19.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb19.getText();
             l5.setText(Sary[3]);
            }
        });
Rb20.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb20.getText();
             l5.setText(Sary[3]);
            }
        });
Rb16.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb16.getText();
             l5.setText(Sary[3]);
            }
        });
Rb17.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb17.getText();
             l5.setText(Sary[3]);
            }
        });
Rb18.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[3]= Rb18.getText();
             l5.setText(Sary[3]);
            }
        });
ImageIcon s1 = new ImageIcon("images\\LS1.jpg");
JLabel ls1 = new JLabel(" ", s1, JLabel.CENTER);

BG4.add(Rb20);
BG4.add(Rb19);
BG4.add(Rb16);
BG4.add(Rb17);
BG4.add(Rb18);

b4.add( Box.createRigidArea(new Dimension(0,50)));
b4.add(Rb20);
b4.add(pl1);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb19);
b4.add(pl2);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb16);
b4.add(pl3);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb17);
b4.add(pl4);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb18);
b4.add(pl5);
b4.add(ls1);

b4.setVisible(false);
b4.setBounds(125, 0, 275, 450);
b4.setBorder(BorderFactory.createTitledBorder(" "));
btnV=new JButton("SCREEN");
btnV.setMaximumSize(new Dimension(120, 25));
con.add(b4);

btnV.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b4.setVisible(true);  
         b1.setVisible(false);
         b3.setVisible(false);
         b2.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         }
});


//typ
pl1=new JLabel("Price - Rs. "+ priceList1[count++]);
pl2=new JLabel("Price - Rs. "+ priceList1[count++]);
pl3=new JLabel("Price - Rs. "+ priceList1[count++]);
pl4=new JLabel("Price - Rs. "+ priceList1[count++]);
pl5=new JLabel("Price - Rs. "+ priceList1[count++]);

final Box hb1= Box.createHorizontalBox();
final Box hb2= Box.createHorizontalBox();
final Box hb3= Box.createHorizontalBox();
final Box hb4= Box.createHorizontalBox();

final Box hb11= Box.createHorizontalBox();
final Box hb12= Box.createHorizontalBox();
//final Box hb13= Box.createHorizontalBox();
//final Box hb14= Box.createHorizontalBox();

ImageIcon i1 = new ImageIcon("images\\LM1.jpg");
JLabel LM1 = new JLabel(" ", i1, JLabel.CENTER);

ImageIcon i2 = new ImageIcon("images\\LM2.jpg");
JLabel LM2 = new JLabel(" ", i2, JLabel.CENTER);

ImageIcon i3 = new ImageIcon("images\\LM3.jpg");
JLabel LM3 = new JLabel(" ", i3, JLabel.CENTER);

ImageIcon i4 = new ImageIcon("images\\LM4.jpg");
JLabel LM4 = new JLabel(" ", i4, JLabel.CENTER);

ImageIcon i5 = new ImageIcon("images\\LM5.jpg");
JLabel LM5 = new JLabel(" ", i5, JLabel.CENTER);


Rb21= new JRadioButton("HP Probook 4530s");
Rb22= new JRadioButton("HP Pavilion DV6");
Rb23= new JRadioButton("Dell Vostro");
Rb24= new JRadioButton("Dell Inspiron N5110");
Rb25= new JRadioButton("Acer Aspire 5750");

BG5.add(Rb21);
BG5.add(Rb22);
BG5.add(Rb23);
BG5.add(Rb24);
BG5.add(Rb25);

hb1.add(LM1);
hb2.add(Rb21);
hb11.add(pl1);
hb11.add( Box.createRigidArea(new Dimension(10,0)));
hb11.add(pl2);
hb1.add(LM2);
hb2.add(Rb22);

b5.add(hb1);
b5.add(hb2);
b5.add(hb11);

hb3.add(LM3);
hb4.add(Rb23);
hb3.add(LM4);
hb4.add(Rb24);
hb12.add(pl3);
hb12.add( Box.createRigidArea(new Dimension(10,0)));
hb12.add(pl4);
b5.add(hb3);
b5.add(hb4);
b5.add(hb12);

b5.add(LM5);
b5.add(Rb25);
b5.add(pl5);

Rb21.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb21.getText();
             l1.setText(Sary[4]);
            }
        });
Rb22.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb22.getText();
             l1.setText(Sary[4]);
            }
        });
Rb23.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb23.getText();
             l1.setText(Sary[4]);
            }
        });
Rb24.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb24.getText();
             l1.setText(Sary[4]);
            }
        });
Rb25.addActionListener( new ActionListener() {          
            public void actionPerformed(ActionEvent e) {
            Sary[4]= Rb25.getText();
             l1.setText(Sary[4]);
            }
        });

b5.setVisible(false);
b5.setBounds(125, 0, 275, 450);
b5.setBorder(BorderFactory.createTitledBorder(" "));
btnD=new JButton("MODEL");
btnD.setMaximumSize(new Dimension(120, 25));
con.add(b5);

btnD.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b5.setVisible(true);  
         b1.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b2.setVisible(false);
         first.setVisible(false);
       
         }
   });
//Submit
Sub = new JButton(" SUBMIT ");
Sub.setMaximumSize(new Dimension(120, 25));
Sub.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
                  ProductsSelectionLaptop1 PSL1 =new ProductsSelectionLaptop1();
                  try {
                 setVisible(false);
                 PSL1.getPrice(Sary);
                  }
                  catch (ClassNotFoundException e1) {
                 System.out.println("Class not found!");
                  }
                  catch (SQLException e1) {
                 e1.printStackTrace();
                  }
         }
   });

buy.add(l1);
buy.add(l2);
buy.add(l3);
buy.add(l4);
buy.add(l5);


rem = new JButton(" Remove ");
rem.setMaximumSize(new Dimension(120, 25));
rem.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         for(int x=0;x<Sary.length;x++){
                 Sary[x]=" ";
         }
         l1.setText(" ");
         l2.setText(" ");
         l3.setText(" ");
         l4.setText(" ");
         l5.setText(" ");
                 
         }
   });
choz.add( Box.createRigidArea(new Dimension(0,50)));
choz.add(btnD);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnP);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnR);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnH);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnV);

buy.add( Box.createRigidArea(new Dimension(0,50)));
ImageIcon image = new ImageIcon("images\\1.jpg");
JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
buy.add(label1);
buy.add(Sub);
buy.add(rem);
choz.setBorder(BorderFactory.createTitledBorder("Choose "));
choz.setBounds(0, 0, 125, 450);
con.add(choz);
}
public void back(String[] ar){
    for(int x=0;x<5;x++){
    Sary[x]= ar[x];
    }
   
            l2.setText(Sary[0]);
            l3.setText(Sary[1]);
            l4.setText(Sary[2]);
            l5.setText(Sary[3]);
            l1.setText(Sary[4]);
           
   }
public void actionPerformed(ActionEvent e) {

}


}


class GetNew1 {

public String[] getData() throws SQLException, ClassNotFoundException{

String[] priceList1 =new String[25];
Connection connection1 =null;
Statement stmt1 =null;
int count =0;


connection1=Jdbc.createConnection();
stmt1 =connection1.createStatement();
ResultSet result1 =stmt1.executeQuery("SELECT * FROM processor");
while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM ram");
while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM harddrive");
while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM display");
while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
result1 =stmt1.executeQuery("SELECT* FROM type");
while(result1.next())
{
priceList1[count++] =result1.getString("Price");
}
connection1.close();
stmt1.close();
return priceList1;
}
}


class ProductsSelectionLaptop1 {

public void getPrice(String[] products) throws SQLException, ClassNotFoundException
{
int count =0;
double[] priceProduct1 =new double[5];
Connection connection1 =null;
Statement stmt1 =null;
String name1;
double price1;
int cnt1 =0;

try
{
connection1   =Jdbc.createConnection();
stmt1 =connection1.createStatement();
ResultSet result1 =stmt1.executeQuery("SELECT * FROM processor");
if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");


if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;


}
}
}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM ram");

if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{

name1 =result1.getString("Name");
price1 =result1.getDouble("Price");

if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}
}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM harddrive");

if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");

if(name1.equals(products[cnt1]))
{

priceProduct1[count++] =price1;
}
}
}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM display");
if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");

if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}
}
cnt1++;
result1 =stmt1.executeQuery("SELECT* FROM type");
if(products[cnt1].equals(" "))
{
priceProduct1[count++] =0.0;
}
else
{
while(result1.next())
{
name1 =result1.getString("Name");
price1 =result1.getDouble("Price");
if(name1.equals(products[cnt1]))
{
priceProduct1[count++] =price1;
}
}
}
cnt1++;
}
catch(SQLException e)
{
System.out.println(e.toString());
}
finally
{
connection1.close();
stmt1.close();
}
SubmitGui sub1 =new SubmitGui(1,products,priceProduct1);
}
}


class purAddLapDB {
static int purNum=2;
    public void sql(String[]ar,double total) throws InstantiationException, IllegalAccessException, ClassNotFoundException{
        try{
         Connection co= Jdbc.createConnection();    
         Statement stm =co.createStatement();
         String s1 = "SELECT PurNo  from AddDBLap";
       
         ResultSet rs = stm.executeQuery(s1);
         int no = 0;
         while (rs.next()) {
                     no= Integer.parseInt( rs.getString("PurNo"));
                   
         }
       
         PreparedStatement pstmt = co.prepareStatement("INSERT INTO AddDBLap " +"VALUES (?,?, ?, ?, ?, ?, ?, ?)");
         String str=new User().getUser();
         pstmt.setInt(1, ++no);
         pstmt.setString(2, str);
         for(int x=0,y=3;x!=5;x++,y++){
        pstmt.setString(y, ar[x]);
         }
         pstmt.setDouble(8, total);
         pstmt.executeUpdate();
       }
       catch(SQLException e){
        System.out.println(e.toString());
       }
    }
}
public class LgMain {
public static void main(String args[]){
LUi l1=new LUi();
}
}




I will show you some of the screen shots of our project.