Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

could u guys help me in this GUI and database problem

 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was tryin to make a small application before i jump into my scjd project...

I was tryin to make a small swing based application. It has a menu and a adjacent screen to display results. Through the file menu..i can choose and go through any files(txt) in my computer. There is going to be a load button which esentially reads the file and displays it on the screen(full unformatted) and a analyis button whicch formats the file and displays the result.

The file im talkin of is like

NAME UNIT PRICE
java mug 2 9.99$
java book 3 19.99$
.....

The output

total price

price for java mug = 20
price for java book = 60
.....
total price = ...

guys could u help me in makeing the file menu and how should i do the open file option.. and then how would i be able to read the file and diplay it on the adjacent text screen.

Any form of suggestion would be helpful...

thanx

abhi
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi abhi,

I think it�s a good idea what you are doing, practicing with some small programs. I�d like to suggest a different exercise. Something like this:

Step 1. Read and write records to a RandomAccessFile.

All records have the same length. A record has 3 fields. The first field is an integer (4 bytes, binary data). The second field is ASCII text padded with spaces. The third field is ASCII digits padded with spaces.

Step 2. Create a GUI with a JTable and a TableModel (and a menu and some buttons, if you want). Read the records from the RandomAccessFile and display them in the JTable. Change the values in the JTable and update the record in the file.

To learn how to use JTables and the TableModel, http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

Marlene
 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the same situation as Abhi,

I really appreciate your exercise suggestion Marlene! I was aware I needed to use JTable, but did not know any documentation on it. Thanks!
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sean. Marlene

Step 3. Add a search button and two text fields above the JTable. Enter data into the text fields. Push the search button. Search the RandomAccessFile for all records matching the specified data. Move the data from the records to the TableModel to the JTable.

Step 4. Add a book button to the JTable. Select a row in the JTable. Change some data in the row. Push the book button. Replace the record in the file with the changed row.

Step 5. Run two programs, a client and a server. The RandomAccessFile goes on the server. Write a server program to read and find records. Use RMI to access the file from the client.
[ October 15, 2004: Message edited by: Marlene Miller ]
 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marlene or anyone out there,

I'm having trouble importing data into the JTable.

When I receive data from the RandomAccessFile, should I create a Vector, ArrayList or an Object array?

I just loop thru and insert items into the array and then do the same to put them into the JTable, correct?

Thx in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic