Appendix I

TheDemo Application

 

Previous

Table of Contents

Next

 

// TheDemo.java

// Further testing of both DatabaseConnect and Mapping

// Creates a GUI and demonstrates further functionality of both classes.

 

import java.awt.*;

import java.util.*;

 

public class TheDemo extends Frame {

 

    // Declaration of elements of interface

    Button winBtn,infoBtn, changeLineBtn, addLineBtn,removeLineBtn,databaseBtn;

 

     Panel welcome;

      Label heading,greeting,welLabel3,welLabel7,welLabel8,welLabel9;

 

      Panel addLine;

      Button addLineButton;

      TextField no1,no2,no4,no5,no6,no3;

      Label infoLabel5,infoLabel6;

      TextArea verification;

      TextField uniqueId;

      Label infoLabel2,infoLabel3,infoLabel4;

 

      Panel changeLine;

      Button changeLineButton;

      TextField chNo1,chNo2,chNo4,chNo5,chNo6,chNo3,changeLineId;

      Label chLabel5,chLabel4,chLabel6,chLabel2,chLabel3;

      TextArea changeLineVerification;

 

      Panel winPanel;

      Button checkWinButton;

      TextField  checkWinNo3,checkWinNo6,checkWinNo5,checkWinNo2;

     TextField checkWinNo1, checkWinNo4,checkWinBonus;

      Label chklabel4,chklabel5,chklabel6,chklabel1;

      TextArea checkWinResults;

 

      Panel removeLine;

      Button removeButton;

      Label removeLabel4,removeLabel6,removeLabel2,removeLabel3;

      Label removeLabel1;

      TextArea removeResults;

      TextField removeId;

 

      Panel database;

      Button queryButton;

      TextArea databaseResults;

      Label dbLabel4,dbLabel6,dbLabel1,dbLabel2,dbLabel5,dbLabel7,dbLabel3;

      TextField userName,password,urlField,queryField;

 

      Panel information;

      Label label1,label2,label3,infoLabel8,infoLabel9,infolabel1,infoLabel7;

      Label infolabel2,infolabel3,infolabel4,infolabel5;

 

      // Declaration of DatabaseConnect variable for use with the database

      // button to connect to and query any database

      DatabaseConnect data;

      String url="";

      String name="";

      String thePassword="";

      String sql="";

 

 

    // Constructor

    public TheDemo() {

       

 

                setLayout(null);

                addNotify();

                resize(insets().left + insets().right + 636,insets().top + insets().bottom + 450);

                setBackground(new Color(8421504));

 

                winBtn = new Button("Check win");

                winBtn.reshape(insets().left + 49,insets().top + 85,81,39);

                add(winBtn);

 

                infoBtn = new Button("Information");

                infoBtn.reshape(insets().left + 50,insets().top + 32,81,38);

                add(infoBtn);

 

                changeLineBtn = new Button("Change line");

                changeLineBtn.reshape(insets().left + 48,insets().top + 143,81,37);

                add(changeLineBtn);

 

                addLineBtn = new Button("Add line");

                addLineBtn.reshape(insets().left + 46,insets().top + 203,81,38);

                add(addLineBtn);

 

                removeLineBtn = new Button("Remove line");

                removeLineBtn.reshape(insets().left + 45,insets().top + 268,81,38);

                add(removeLineBtn);

 

                databaseBtn = new Button("Database");

                databaseBtn.reshape(insets().left + 45,insets().top + 330,81,38);

                add(databaseBtn);

 

                welcome = new Panel();

                welcome.setLayout(null);

                welcome.reshape(insets().left + 192,insets().top + 0,443,435);

                welcome.setBackground(new Color(12632256));

                add(welcome);

 

                heading = new Label("Failte Romhat");

                heading.reshape(151,24,130,34);

                heading.setFont(new Font("TimesRoman", Font.BOLD, 18));

                welcome.add(heading);

 

                greeting = new Label("Welcome to the Lotto application");

                greeting.reshape(111,78,223,22);

                welcome.add(greeting);

 

                welLabel3 = new Label("The function of this application is to demonstrate”+

                            “ the usage of the");

                welLabel3.reshape(16,145,414,26);

                welcome.add(welLabel3);

 

                welLabel7 = new Label("classes DatabaseConnect and Mapping");

                welLabel7.reshape(19,172,376,24);

                welcome.add(welLabel7);

 

                welLabel8 = new Label("Click on the appropriate button to bring up the”+

                         “ screen   to carry");

                welLabel8.reshape(18,246,373,30);

                welcome.add(welLabel8);

 

                welLabel9 = new Label("out the required task.");

                welLabel9.reshape(18,279,367,24);

                welcome.add(welLabel9);

 

                addLine = new Panel();

                addLine.setLayout(null);

                addLine.hide();

                addLine.reshape(insets().left + 192,insets().top + 0,443,435);

                addLine.setBackground(new Color(12632256));

                add(addLine);

 

                addLineButton = new Button("Add Line");

                addLineButton.reshape(196,206,89,19);

                addLineButton.setFont(new Font("Dialog", Font.BOLD, 12));

                addLine.add(addLineButton);

 

                no1 = new TextField();

                no1.reshape(100,85,37,24);

                no1.setForeground(new Color(255));

                addLine.add(no1);

 

                no2 = new TextField();

                no2.reshape(147,85,37,24);

                no2.setForeground(new Color(255));

                addLine.add(no2);

 

                no4 = new TextField();

                no4.reshape(245,84,37,24);

                no4.setForeground(new Color(255));

                addLine.add(no4);

 

                no5 = new TextField();

                no5.reshape(294,84,37,24);

                no5.setForeground(new Color(255));

                addLine.add(no5);

 

                no6 = new TextField();

                no6.reshape(341,84,37,24);

                no6.setForeground(new Color(255));

                addLine.add(no6);

 

                no3 = new TextField();

                no3.reshape(197,84,37,24);

                no3.setForeground(new Color(255));

                addLine.add(no3);

 

                infoLabel5 = new Label("Enter six new numbers");

                infoLabel5.reshape(149,48,183,26);

                infoLabel5.setFont(new Font("Courier", Font.BOLD, 12));

                addLine.add(infoLabel5);

 

                infoLabel6 = new Label("Verification of new line");

                infoLabel6.reshape(112,260,252,37);

                infoLabel6.setFont(new Font("Courier", Font.BOLD, 16));

                addLine.add(infoLabel6);

 

                verification = new TextArea();

                verification.setEditable(false);

                verification.reshape(12,308,412,81);//.reshape(12,308,408,81);

                verification.setBackground(new Color(16777215));

                addLine.add(verification);

 

                uniqueId = new TextField();

                uniqueId.reshape(165,157,149,31);

                addLine.add(uniqueId);

 

                infoLabel2 = new Label("Enter Line Identifier");

                infoLabel2.reshape(152,132,180,20);

                infoLabel2.setFont(new Font("Courier", Font.BOLD, 12));

                addLine.add(infoLabel2);

 

                infoLabel3 = new Label("____________________________"+

                "______________________________________");

                infoLabel3.reshape(-12,230,445,22);

                addLine.add(infoLabel3);

 

                infoLabel4 = new Label("Add a new line");

                infoLabel4.reshape(135,2,228,41);

                infoLabel4.setFont(new Font("Courier", Font.BOLD, 22));

                addLine.add(infoLabel4);

 

                changeLine = new Panel();

                changeLine.setLayout(null);

                changeLine.hide();

                changeLine.reshape(insets().left + 192,insets().top + 0,443,435);

                changeLine.setBackground(new Color(12632256));

                add(changeLine);

 

                chLabel4 = new Label("Change a line");

                chLabel4.reshape(135,2,228,41);

                chLabel4.setFont(new Font("Courier", Font.BOLD, 22));

                changeLine.add(chLabel4);

 

                changeLineButton = new Button("Change Line");

                changeLineButton.reshape(196,206,89,19);

                changeLine.add(changeLineButton);

 

                chNo1 = new TextField();

                chNo1.reshape(94,85,37,24);

                chNo1.setForeground(new Color(255));

                changeLine.add(chNo1);

 

                chNo2 = new TextField();

                chNo2.reshape(141,85,37,24);

                chNo2.setForeground(new Color(255));

                changeLine.add(chNo2);

 

                chNo4 = new TextField();

                chNo4.reshape(239,84,37,24);

                chNo4.setForeground(new Color(255));

                changeLine.add(chNo4);

 

                chNo5 = new TextField();

                chNo5.reshape(288,84,37,24);

                chNo5.setForeground(new Color(255));

                changeLine.add(chNo5);

 

                chNo6 = new TextField();

                chNo6.reshape(335,84,37,24);

                chNo6.setForeground(new Color(255));

                changeLine.add(chNo6);

 

                chNo3 = new TextField();

                chNo3.reshape(191,84,37,24);

                chNo3.setForeground(new Color(255));

                changeLine.add(chNo3);

 

                chLabel5 = new Label("Enter six new numbers");

                chLabel5.reshape(149,48,183,26);

                chLabel5.setFont(new Font("Courier", Font.BOLD, 12));

                changeLine.add(chLabel5);

 

                chLabel6 = new Label("Verification of change");

                chLabel6.reshape(112,260,252,37);

                chLabel6.setFont(new Font("Courier", Font.BOLD, 16));

                changeLine.add(chLabel6);

 

                changeLineVerification = new TextArea();

                changeLineVerification.setEditable(false);

                changeLineVerification.reshape(12,308,412,81);

                changeLineVerification.setBackground(new Color(16777215));

                changeLine.add(changeLineVerification);

 

                changeLineId = new TextField();

                changeLineId.reshape(165,157,149,31);

                changeLine.add(changeLineId);

 

                chLabel2 = new Label("Enter Line Identifier");

                chLabel2.reshape(152,132,180,20);

                chLabel2.setFont(new Font("Courier", Font.BOLD, 12));

                changeLine.add(chLabel2);

 

                chLabel3 = new Label("_________________________________"+

                "_________________________________");

                chLabel3.reshape(-11,230,445,22);

                changeLine.add(chLabel3);

 

                winPanel = new Panel();

                winPanel.setLayout(null);

                winPanel.hide();

                winPanel.reshape(insets().left + 192,insets().top + 0,443,435);

                winPanel.setBackground(new Color(12632256));

                add(winPanel);

 

                checkWinNo3 = new TextField();

                checkWinNo3.reshape(169,80,37,24);

                checkWinNo3.setForeground(new Color(255));

                winPanel.add(checkWinNo3);

 

                chklabel5 = new Label("Bonus");

                chklabel5.reshape(360,51,56,26);

                winPanel.add(chklabel5);

 

                checkWinNo6 = new TextField();

                checkWinNo6.reshape(314,79,37,24);

                checkWinNo6.setForeground(new Color(255));

                winPanel.add(checkWinNo6);

 

                checkWinNo5 = new TextField();

                checkWinNo5.reshape(267,79,37,24);

                checkWinNo5.setForeground(new Color(255));

                winPanel.add(checkWinNo5);

 

                checkWinNo2 = new TextField();

                checkWinNo2.reshape(120,80,37,24);

                checkWinNo2.setForeground(new Color(255));

                winPanel.add(checkWinNo2);

 

                checkWinNo1 = new TextField();

                checkWinNo1.reshape(73,80,37,24);

                checkWinNo1.setForeground(new Color(255));

                winPanel.add(checkWinNo1);

 

                chklabel4 = new Label("Enter seven numbers ");

                chklabel4.reshape(164,47,148,26);

                winPanel.add(chklabel4);

 

                checkWinButton = new Button("Compare");

                checkWinButton.reshape(179,137,89,19);

                winPanel.add(checkWinButton);

 

                chklabel6 = new Label("Results");

                chklabel6.reshape(188,167,78,22);

                winPanel.add(chklabel6);

 

                chklabel1 = new Label("Check for a win");

                chklabel1.reshape(122,7,236,36);

                chklabel1.setFont(new Font("Courier", Font.BOLD, 22));

                winPanel.add(chklabel1);

 

                checkWinResults = new TextArea();

                checkWinResults.setEditable(false);

                checkWinResults.reshape(50,200,376,220);

                checkWinResults.setBackground(new Color(16777215));

                winPanel.add(checkWinResults);

 

                checkWinNo4 = new TextField();

                checkWinNo4.reshape(218,79,37,24);

                checkWinNo4.setForeground(new Color(255));

                winPanel.add(checkWinNo4);

 

                checkWinBonus = new TextField();

                checkWinBonus.reshape(372,80,37,24);

                checkWinBonus.setForeground(new Color(16711680));

                winPanel.add(checkWinBonus);

 

                removeLine = new Panel();

                removeLine.setLayout(null);

                removeLine.hide();

                removeLine.reshape(insets().left + 192,insets().top + 0,443,435);

                removeLine.setBackground(new Color(12632256));

                add(removeLine);

 

                removeLabel4 = new Label("Remove a line");

                removeLabel4.reshape(127,2,228,41);

                removeLabel4.setFont(new Font("Courier", Font.BOLD, 22));

                removeLine.add(removeLabel4);

 

                removeButton = new Button("Remove line");

                removeButton.reshape(181,188,89,19);

                removeLine.add(removeButton);

 

                removeLabel6 = new Label("Verification that line was removed");

                removeLabel6.reshape(46,263,367,37);

                removeLabel6.setFont(new Font("Courier", Font.BOLD, 16));

                removeLine.add(removeLabel6);

 

                removeResults = new TextArea();

                removeResults.setEditable(false);

                removeResults.reshape(67,308,323,81);

                removeResults.setBackground(new Color(16777215));

                removeLine.add(removeResults);

 

                removeId = new TextField();

                removeId.reshape(152,106,149,31);

                removeLine.add(removeId);

 

                removeLabel2 = new Label("Enter Line Identifier");

                removeLabel2.reshape(138,71,180,20);

                removeLabel2.setFont(new Font("Courier", Font.BOLD, 12));

                removeLine.add(removeLabel2);

 

                removeLabel3 = new Label("__________________________________"+

                "_________________________________");

                removeLabel3.reshape(-11,230,445,22);

                removeLine.add(removeLabel3);

 

                removeLabel1 = new Label("Press to remove line");

                removeLabel1.reshape(138,159,180,20);

                removeLabel1.setFont(new Font("Courier", Font.BOLD, 12));

                removeLine.add(removeLabel1);

 

                database = new Panel();

                database.setLayout(null);

                database.hide();

                database.reshape(insets().left + 192,insets().top + 0,443,435);

                database.setBackground(new Color(12632256));

                add(database);

 

                dbLabel4 = new Label("Query a database");

                dbLabel4.reshape(116,2,228,41);

                dbLabel4.setFont(new Font("Courier", Font.BOLD, 22));

                database.add(dbLabel4);

 

                dbLabel6 = new Label("Results");

                dbLabel6.reshape(187,210,97,25);

                dbLabel6.setFont(new Font("Courier", Font.BOLD, 16));

                database.add(dbLabel6);

 

                databaseResults = new TextArea();

                databaseResults.setEditable(false);

                databaseResults.reshape(4,235,435,193);

                databaseResults.setBackground(new Color(16777215));

                database.add(databaseResults);

 

                dbLabel1 = new Label("Username");

                dbLabel1.reshape(29,50,113,26);

                database.add(dbLabel1);

 

                dbLabel2 = new Label("Password");

                dbLabel2.reshape(31,78,116,24);

                database.add(dbLabel2);

 

                dbLabel5 = new Label("Database URL");

                dbLabel5.reshape(31,102,125,30);

                database.add(dbLabel5);

 

                dbLabel7 = new Label("SQL query");

                dbLabel7.reshape(30,138,81,22);

                database.add(dbLabel7);

 

                userName = new TextField();

                userName.reshape(157,48,206,28);

                database.add(userName);

 

                password = new TextField();

                password.reshape(157,77,206,28);

                database.add(password);

 

                urlField = new TextField();

                urlField.reshape(157,105,206,28);

                database.add(urlField);

 

                queryField = new TextField();

                queryField.reshape(118,133,301,28);

                database.add(queryField);

 

                queryButton = new Button("Submit query");

                queryButton.reshape(156,169,184,25);

                database.add(queryButton);

 

                dbLabel3 = new Label("______________________________"+

        "_____________________________________");

                dbLabel3.reshape(-12,194,445,16);

                database.add(dbLabel3);

 

                information = new Panel();

                information.setLayout(null);

                information.hide();

                information.reshape(insets().left + 192,insets().top + 0,443,435);

                information.setBackground(new Color(12632256));

                add(information);

 

                label1 = new Label("Information");

                label1.reshape(151,24,130,34);

                label1.setFont(new Font("TimesRoman", Font.BOLD, 18));

                information.add(label1);

 

                label2 = new Label("Check win enables you to enter seven numbers and”+

                                “ compare");

                label2.reshape(27,82,402,22);

                information.add(label2);

 

                label3 = new Label("Change line enables you to change the values stored “+

                                “for a particular");

                label3.reshape(24,139,414,26);

                information.add(label3);

 

                infoLabel8 = new Label("Database enables you to perform database “+

                                “operations, such as");

                infoLabel8.reshape(23,341,410,30);

                information.add(infoLabel8);

 

                infoLabel9 = new Label("insert, delete and retrieve information.");

                infoLabel9.reshape(23,371,367,24);

                information.add(infoLabel9);

 

                infolabel1 = new Label("them to the numbers stored in the Lotto database.");

                infolabel1.reshape(27,103,402,22);

                information.add(infolabel1);

 

                infoLabel7 = new Label("line.  Each line requires a unique identifier, i.e.”+

                                “person name.");

                infoLabel7.reshape(24,163,376,24);

                information.add(infoLabel7);

                infolabel2 = new Label("Add line enables you to add a new set of numbers”+

                                “ to the database.");

                infolabel2.reshape(22,208,414,26);

                information.add(infolabel2);

 

                infolabel3 = new Label("Each line requires a unique identifier, i.e. “+

                                “person name.");

                infolabel3.reshape(23,233,376,24);

                information.add(infolabel3);

 

                infolabel4 = new Label("Remove line enables you to delete a set of numbers”+

                                “ from the");

                infolabel4.reshape(25,275,414,26);

                information.add(infolabel4);

 

                infolabel5 = new Label("database.  Each line requires a unique identifier,”+

                                “ i.e. person name.");

                infolabel5.reshape(25,299,394,24);

                information.add(infolabel5);

 

                setTitle("Demonstration of the classes DatabaseConnect and Mapping");

 

             }

 

          // Constructor which accepts a title for the Frame

          public TheDemo(String title) {

                    this();

                    setTitle(title);

          }

 

         public synchronized void show() {

                move(50, 50);

                super.show();

         }

 

 

                public boolean handleEvent(Event event) {

                if (event.id == Event.WINDOW_DESTROY) {

                   hide();         // hide the Frame

                       return true;

                }

                if (event.target == infoBtn && event.id == Event.ACTION_EVENT) {

                                infoBtn_Clicked(event);

                                return true;

                }

                if (event.target == winBtn && event.id == Event.ACTION_EVENT) {

                                winBtn_Clicked(event);

                                return true;

                }

if (event.target == changeLineBtn && event.id == Event.ACTION_EVENT) {

                                changeLineBtn_Clicked(event);

                                return true;

                }

                if (event.target == addLineBtn && event.id == Event.ACTION_EVENT) {

                                addLineBtn_Clicked(event);

                                return true;

                }

if (event.target == removeLineBtn && event.id == Event.ACTION_EVENT) {

                                removeLineBtn_Clicked(event);

                                return true;

                }

                if (event.target == databaseBtn && event.id == Event.ACTION_EVENT) {

                                databaseBtn_Clicked(event);

                                return true;

                }

                if (event.target == addLineButton && event.id == Event.ACTION_EVENT) {

                                addLineButton_Clicked(event);

                                return true;

                }

if (event.target==changeLineButton && event.id== Event.ACTION_EVENT) {

                                changeLineButton_Clicked(event);

                                return true;

                }

if (event.target == checkWinButton && event.id == Event.ACTION_EVENT) {

                                checkWinButton_Clicked(event);

                                return true;

                }

                if (event.target == removeButton && event.id == Event.ACTION_EVENT) {

                                removeButton_Clicked(event);

                                return true;

                }

                if (event.target == queryButton && event.id == Event.ACTION_EVENT) {

                                queryButton_Clicked(event);

                                return true;

                }

                return super.handleEvent(event);

      }

 

         // Actions carried out when the buttons are clicked

          void queryButton_Clicked(Event event) {

          name= userName.getText();

          sql=queryField.getText();

          url=urlField.getText();

          thePassword=password.getText();

 

          String contents=new String(urlField.getText());

         System.out.println("Contents Of contents = "+contents);

         if(contents.length()>3){

             data=new DatabaseConnect(url,name,thePassword);

         }

         else{

            data=new DatabaseConnect();

        }

        data.openConn();

        data.createStmt();

        databaseResults.append(sql);

 

        System.out.println(sql);

 

        Vector results;

        results =data.getDisplayableResults(sql);

 

        displayResults(results,databaseResults);

        //database.createResultSet(sql);

        data.closeAll();

 

 

   }

   void removeButton_Clicked(Event event) {

 

        String remove =removeId.getText();

        Lotto removable = new Lotto(remove);

        removable.delete();

        String theName = removable.getIdentifier();

        removeResults.append("The Line identified by "+theName+"\n"+

                                        "has been successfully removed\n");

   }

 

void checkWinButton_Clicked(Event event) {

      try{

 

        // get the identifiers of the lotto objects stored in the database

        // place them in a resultset and use them to reinitialise each of the

        // lotto objects.

 

         String query="SELECT owner FROM lotto";

         checkWinResults.append("Getting the identifiers of each Lotto object\n");

 

         Hashtable names=Framework.getObjectIdentifiers(query);

         for(int i=1; i<=names.size();i++){

             Integer no=new Integer(i);

             System.out.println(i+"  "+names.get(no.toString()));

         }

 

        // Initialise all the lotto objects for which attributes are

        // stored in a database table

        int rows=names.size();

        checkWinResults.append("Initialising "+rows+" Lotto objects\n \n");        

        Lotto numbers[] = new Lotto[rows];

        int j=1;

        for(int i=0;i<rows;i++){

             Integer no=new Integer(j);

             String id=names.get(no.toString()).toString();

             numbers[i]=new Lotto(id);

             checkWinResults.append(j+"-");

             j++;

 

        }

 

 

        checkWinResults.append("\nExtracting values from the interface\n \n");

        // Get values from the interface

        int line[] =new int[7];

        line[0]= new Integer(checkWinNo1.getText()).intValue();

        line[1]= new Integer(checkWinNo2.getText()).intValue();

        line[2]= new Integer(checkWinNo3.getText()).intValue();

        line[3]= new Integer(checkWinNo4.getText()).intValue();

        line[4]= new Integer(checkWinNo5.getText()).intValue();

        line[5]= new Integer(checkWinNo6.getText()).intValue();

        line[6]= new Integer(checkWinBonus.getText()).intValue();

 

        // Display the winning numbers

        checkWinResults.append("Winning numbers = ");

        for(int i=0;i<line.length-1;i++){

            checkWinResults.append(line[i]+ " ");

        }

        checkWinResults.append(" Bonus no = "+line[6]+"\n");

 

        for(int i=0;i<rows;i++){

        numbers[i].checkLine(line);

        numbers[i].checkWin();

        if(numbers[i].matchCount>0){

             checkWinResults.append(numbers[i].results+"\n");

         }

     }

     catch(Exception e){

           System.err.println(e.getMessage());

      }

   }

 

    void changeLineButton_Clicked(Event event) {

        int numbers[]=new int[6];

        String nos[]=new String[6];

        nos[0]=chNo1.getText();

        nos[1]=chNo2.getText();

        nos[2]=chNo3.getText();

        nos[3]=chNo4.getText();

        nos[4]=chNo5.getText();

        nos[5]=chNo6.getText();

               

        for(int i=0;i<6;i++){

                 Integer no =new Integer(nos[i]);

                 numbers[i]=no.intValue();

        }

 

          String lineName = changeLineId.getText();

          Lotto change=new Lotto(lineName);

 

          change.changeValue("Number1",numbers[0]);

          change.changeValue("Number2",numbers[1]);

          change.changeValue("Number3",numbers[2]);

             change.changeValue("Number4",numbers[3]);

             change.changeValue("Number5",numbers[4]);

            change.changeValue("Number6",numbers[5]);

             String aQuery=("SELECT * FROM lotto WHERE Owner LIKE "+"'"+

         change.getValue("Owner")+"'");

         Vector results;

         data=new DatabaseConnect();

         results =data.getDisplayableResults(aQuery);

         displayResults(results,changeLineVerification);

         data.closeAll();

 

   }

    void addLineButton_Clicked(Event event) {

        int num[]=new int[6];

        String nos[]=new String[6];

        nos[0]=no1.getText();

        nos[1]=no2.getText();

        nos[2]=no3.getText();

        nos[3]=no4.getText();

        nos[4]=no5.getText();

        nos[5]=no6.getText();

         for(int i=0;i<6;i++){

                    Integer no =new Integer(nos[i]);

                    num[i]=no.intValue();

                    System.out.print(num[i]+" ");

       }

 

        System.out.println("");

        String name = uniqueId.getText();

        //System.out.println(" Value in uniqueId = "+name);

        //System.out.println("So Far so good (664) ");

        Lotto newLine=new(Lotto(num[0],num[1],num[2],num[3],num[4],

                        num[5],name);

        //Lotto newLine=new Lotto(1,2,3,4,5,6,"bos");

        //System.out.println("So Far so good (663) ");

        newLine.store();

        //System.out.println("So Far so good (664) ");

 

        String aQuery=("SELECT * FROM lotto WHERE Owner LIKE "+

"'"+name+"'");

        data=new DatabaseConnect();

       /*String info="INSERT INTO lotto VALUES ("+num[0]+", "+num[1]+",   

         "+num[2]+", "+ num[3]+", "+num[4]+", "+num[5]+", "+"'"+name+"')";

         */

         //data.openConn();

         //data.createStmt();

         //data.exeSql(info);

        System.out.println("Before vector is created: TheDemo(683)");

        Vector results =data.getDisplayableResults(aQuery);

        System.out.println("After vector is created: TheDemo(685)");

        displayResults(results,verification);

 

 

    }

 

    // xxxBtn_Clicked methods handle button events on the left of

    // the interface.

     void databaseBtn_Clicked(Event event) {

                                addLine.hide();

                                changeLine.hide();

                                winPanel.hide();

                                removeLine.hide();

                                database.show();

                                welcome.hide();

                                information.hide();

                }

 

                void removeLineBtn_Clicked(Event event) {

                                addLine.hide();

                                changeLine.hide();

                                winPanel.hide();

                                removeLine.show();

                                database.hide();

                                welcome.hide();

                                information.hide();

                }

 

                void addLineBtn_Clicked(Event event) {

                                addLine.show();

                                changeLine.hide();

                                winPanel.hide();

                                removeLine.hide();

                                database.hide();

                                welcome.hide();

                                information.hide();

                }

 

                void changeLineBtn_Clicked(Event event) {

                                addLine.hide();

                                changeLine.show();

                                winPanel.hide();

                                removeLine.hide();

                                database.hide();

                                welcome.hide();

                                information.hide();

                }

 

                void winBtn_Clicked(Event event) {

                                addLine.hide();

                                changeLine.hide();

                                winPanel.show();

                                removeLine.hide();

                                database.hide();

                                welcome.hide();

                                information.hide();

                }

 

                void infoBtn_Clicked(Event event) {

                                addLine.hide();

                                changeLine.hide();

                                winPanel.hide();

                                removeLine.hide();

                                database.hide();

                                welcome.hide();

                                information.show();

                }

 

   //******************************************************************

   // Static method, accepts a reference to a Vector and a TextArea

   // For display purposes within a TextArea

 

   public static void displayResults(Vector outgoing, TextArea local){

 

       int rows=outgoing.size();

       local.append("\n\n");

 

       for(int i=0;i<outgoing.size();i++){//rows. 10 works

           Hashtable temp=(Hashtable)outgoing.elementAt(i);

           int j=temp.size();

           for(int k=1;k<=j;k++){

               if(k==j){

                   Integer t=new Integer(k);

                   local.append(temp.get(t.toString())+"\n");

               }

               else if(k==1){

                   Integer t=new Integer(k);

                   local.append(temp.get(t.toString())+"\t");

               }

               else{

                   Integer t=new Integer(k);

                   local.append(temp.get(t.toString())+"\t");

               }

           }

       }

   }

 

                public static void main(String args[]){

                    TheDemo myDemo=new TheDemo();

                    myDemo.show();

                    //myFrame.panel1.show();

                }

}

 

Previous

Table of Contents

Next

 

Home