hi,

i am creating a small program for an assignment to store and retrieve information from a database. I have created arraylists to add and retrieve the data. just wondering if i am going about it the right way. One of the problems is that when the information is displayed in the pop up window it displays as [text][text][text] etc. i would like it to display each entry of name, number, address etc on each line. I also would like to know how to store the data in a XML file. thank you.

ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> list2 = new ArrayList<String>();
ArrayList<String> list3 = new ArrayList<String>();
ArrayList<String> list4 = new ArrayList<String>();
ArrayList<String> list5 = new ArrayList<String>();
ArrayList<String> list6 = new ArrayList<String>();

   private void addActionPerformed(java.awt.event.ActionEvent evt) {

String name1 = name.getText();
String number1 = number.getText();
String date1 = date.getText();
String address1 = address.getText();
String salesperson1 = salesperson.getText();
String enquires1 = enquires.getText();


list1.add(name1); String l1 = list1.toString();
list2.add(number1);String l2 = list2.toString();
list3.add(date1);String l3 = list3.toString();
list4.add(address1);String l4 = list4.toString();
list5.add(salesperson1);String l5 = list5.toString();
list6.add(enquires1);String l6 = list6.toString();

data = l1 + l2 + l3 + l4 + l5 + l6;

JOptionPane.showMessageDialog(null, "Customer Details have been entered",
        "Confirmation", JOptionPane.PLAIN_MESSAGE);


    }

    private void followupActionPerformed(java.awt.event.ActionEvent evt) {
         String edate = enquirydate.getText();
         Collections.sort(list3);
         if(list3.contains(edate)){
             JOptionPane.showMessageDialog(null, data,
        "Enquiry Details", JOptionPane.PLAIN_MESSAGE);
        }else if(edate.equals("")){
        JOptionPane.showMessageDialog(null, "Please enter date",
        "Enquiry Details", JOptionPane.PLAIN_MESSAGE);
        }else{JOptionPane.showMessageDialog(null, "No records found",
        "Enquiry Details", JOptionPane.PLAIN_MESSAGE);


        }
    }

    private void clearActionPerformed(java.awt.event.ActionEvent evt) {
name.setText("");
number.setText("");
date.setText("");
address.setText("");
salesperson.setText("");
enquires.setText("");
enquirydate.setText("");
    }

jdiddy

Edited 6 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

data = l1 + l2 + l3 + l4 + l5 + l6;

if data is a String object, try:

data = l1 + "\n" + l2 + "\n" + l3 + "\n" + l4 + "\n" + l5 + "\n" + l6;

as for reading and editing xml files: you might want to check out the JDom package (or a similar one), they're build especially to handle xml files, and are not that hard to figure out

if data is a String object, try:

data = l1 + "\n" + l2 + "\n" + l3 + "\n" + l4 + "\n" + l5 + "\n" + l6;

as for reading and editing xml files: you might want to check out the JDom package (or a similar one), they're build especially to handle xml files, and are not that hard to figure out

Ok kewl that worked fine thanks for the help will check out the xml stuff been strugglin with it so will have to see.

cheers

jdiddy

This article has been dead for over six months. Start a new discussion instead.