File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Some thing better than an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Some thing better than an array" Watch "Some thing better than an array" New topic

Some thing better than an array

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hello world,
I am hoping to write a stock controlling program. In that, I have a function to print a bill. Which the user can add items to the bill with the quantyties...
I am doing this in 'SWING' and I am using the JTable class to show the bill. Means that it has columns such as 'items code', qty, price per uni and subtotal etc..
In my program I have the options of deleting an entry in the bill, undo an entry redo an entry, edit an entry(say you entere 10 pieces for 1 piece accidentally and you want to crrect it.) So far what I did was having the entries in an 2D array and messing with it. It is really hard and results in unexpected erros. Please do advice me a good solution to corp these needs.
More descriptive answeres are very much welcome.

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

Generally, what you want to do here is create a "BillItem" class that looks like:

Then, you put objects of this class into a List (usually an ArrayList) and display that list.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Thank You very much for the answer.
I agree. Here's the link:
subject: Some thing better than an array
It's not a secret anymore!