How to refresh Table

when im putting a data in JTextField. the data in JTextField is automatically insert in database. My problem is the table where the database record view is not update?

any Help!?

tnx in advance?

[213 byte] By [SaGaRaa] at [2007-11-27 10:30:00]
# 1

Without more information it's impossible to tell.

Do you commit the insert?

dwga at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 2

Do you use a JTable?

The table model has a method fireTableDataChanged()

(there are other methods starting with "fire..." in AbstractTableModel)

regards

BugBunny

BugBunnya at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 3

Swing related questions should be posted in the Swing forum.

If you just want to update the value of a cell in a JTable, then use the JTable.setValueAt(...) method.

camickra at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 4

im using TableModel model = new AbstractTableModel.

the method i use is to remove the table then create other table..

SaGaRaa at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 5

> im using TableModel model = new AbstractTableModel.

No you aren't. You can't instaniate an Abstract class.

> the method i use is to remove the table then create other table..

Why? You said you update a text field. This implies only a single cell needs to be updated. So why would you create a whole new TableModel.

camickra at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 6

how can i refresh AbstractTableModel?

SaGaRaa at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 7

> how can i refresh AbstractTableModel?

Did you see my last comment? You are not using AbstractTableModel. You are using some class that extends AbstractTableModel. There is no method to refresh an AbstractTableModel.

You can update a TableModel one cell at a time using the setValueAt(...) method.

You can create a new TableModel and then update the table using the setModel(...) method.

Read the Swing tutorial on "How to Use Tables" for the basics:

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

camickra at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 8

> how can i refresh AbstractTableModel?

um,... did you read camikr's response above? You cannot instantiate much less refresh an abstract object.

petes1234a at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 9

can you give me some code for that..

i have no idea..

tnx..

SaGaRaa at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...
# 10

DefaultTableModel.setValueAt()

ejpa at 2007-7-28 18:00:43 > top of Java-index,Java Essentials,Java Programming...