aspose file tools
The moose likes Beginning Java and the fly likes Some thing better than an array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Some thing better than an array" Watch "Some thing better than an array" New topic
Author

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.
Thanks.
More descriptive answeres are very much welcome.


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

Joined: Aug 20, 2001
Posts: 1815
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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Some thing better than an array
 
Similar Threads
Why????
shallow copy
Java I/O
Programming Structure.
Array to Hashmap