how to use ArrayList

hello.

this is james mcfadden. i am new to ArrayList. how do i modify the following piece(s) of code so that i can use ArrayList?

thanks for the help.

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

import java.util.*;

publicclass ProductFormextends JFrame{

JPanel pnlTitle,pnlBody,pnlFooter;

JButton btnDBAdd=new JButton("Add");

JButton btnDBEdit=new JButton("Edit");

JButton btnDBDelete=new JButton("Delete");

JLabel[] lblForm=new JLabel[14];

JLabel lblTitle=new JLabel("Product Form");

JTextField[] txtFlds=new JTextField[60];

String[] listFormNames={"Product Number","Name","Rental Price","Age Category","Type","Year"};

Container contentpane;

int productNumber;

String name;

float rentalPrice;

String ageCategory;

String type;

int year;

DBController dbc=new DBController();

Product p=new Product();

public ProductForm(){

super("Product");

contentpane=getContentPane();

contentpane.setLayout(new BorderLayout());

pnlTitle=new JPanel();

pnlBody=new JPanel();

pnlFooter=new JPanel();

pnlBody.setLayout(new GridLayout(listFormNames.length,2,20,20));

for(int i=0;i<listFormNames.length;i++){

lblForm[i]=new JLabel(listFormNames[i]);

pnlBody.add(lblForm[i]);

txtFlds[i]=new JTextField(25);

pnlBody.add(txtFlds[i]);

}

lblTitle.setForeground(Color.RED);

pnlTitle.add(lblTitle);

pnlFooter.add(btnDBAdd);

pnlFooter.add(btnDBEdit);

pnlFooter.add(btnDBDelete);

contentpane.add(pnlTitle,BorderLayout.NORTH);

contentpane.add(pnlBody,BorderLayout.CENTER);

contentpane.add(pnlFooter,BorderLayout.SOUTH);

pack();

setVisible(true);

btnDBAdd.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//get the product number

String s=txtFlds[0].getText();

p.setProductNumber(Integer.parseInt(s));

//get the product name

p.setName(txtFlds[1].getText());

//get the rental price

String s2=txtFlds[2].getText();

float f=Float.parseFloat(s2);

p.setRentalPrice(f);

//get the age category

p.setAgeCategory(txtFlds[3].getText());

p.setType(txtFlds[4].getText());

String s3=txtFlds[5].getText();

p.setYear(Integer.parseInt(s3));

dbc.makeConnection();

dbc.setHostURL();

dbc.insertProduct(p);

dbc.closeDB();

}

});

btnDBEdit.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//get the product number

String s=txtFlds[0].getText();

p.setProductNumber(Integer.parseInt(s));

//get the product name

p.setName(txtFlds[1].getText());

dbc.makeConnection();

dbc.setHostURL();

dbc.editProduct(p);

dbc.closeDB();

}

});

btnDBDelete.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

dbc.makeConnection();

dbc.setHostURL();

dbc.deleteProduct(p);

dbc.closeDB();

}

});

}

publicvoid getInput(){

Scanner sc =new Scanner(System.in);

int i = sc.nextInt();

}

}

publicclass Product{

int productNumber;

String name;

float rentalPrice;

String ageCategory;

String type;

int year;

//setters

publicvoid setProductNumber(int a){

this.productNumber = a;

}

publicvoid setName(String b){

this.name = b;

}

publicvoid setRentalPrice(float c){

this.rentalPrice = c;

}

publicvoid setAgeCategory(String d){

this.ageCategory = d;

}

publicvoid setType(String e){

this.type = e;

}

publicvoid setYear(int f){

this.year = f;

}

//getters

publicint getProductNumber(){

return this.productNumber;

}

public String getName(){

return this.name;

}

publicfloat getRentalPrice(){

return this.rentalPrice;

}

public String getAgeCategory(){

return this.ageCategory;

}

public String getType(){

return this.type;

}

publicint getYear(){

return this.year;

}

}

>

[8828 byte] By [james-mcfaddena] at [2007-11-27 8:52:05]
# 1
Use it instead of what?
prometheuzza at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...
# 2
That's not a very clear question.Here's a tutorial. Go through that, and then if you have a specific question, ask. http://java.sun.com/docs/books/tutorial/collections/
jverda at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...
# 3
> Use it instead of what?Instead of not using it. ;-)
jverda at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...
# 4
> > Use it instead of what?> > Instead of not using it. ;-)You're a genuine smart@ss mr. Verd....!; )
prometheuzza at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...
# 5
i want to use ArrayList instead of setters and getters.
james-mcfaddena at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...
# 6
> i want to use ArrayList instead of setters and> getters.You mean instead of setYear, setType, setName, you want to put year, type and name into an ArrayList? Whatever for? That's a horrible idea.
jverda at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...
# 7
james,An ArrayList to replace getters & setters. What? What was your thought(less) process here. I need a laugh.Keith.Message was edited by: corlettk
corlettka at 2007-7-12 21:06:51 > top of Java-index,Java Essentials,Java Programming...