Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28-05-2009
Member
 
Join Date: May 2009
Posts: 1
How to refresh data of Jtable in java

Hi Friends, i have connected my database table to jtable, but i dont no how to refresh that table after adding or removing some data from it.

Thanks
Reply With Quote
  #2  
Old 28-05-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to refresh data of Jtable in java

Listening for Data Changes

A table model can have a set of listeners that are notified whenever the table data changes. Listeners are instances of TableModelListener. In the following example code, SimpleTableDemo is extended to include such a listener.

import javax.swing.event.*;
import javax.swing.table.TableModel;

public class SimpleTableDemo ... implements TableModelListener {
...
public SimpleTableDemo() {
...
table.getModel().addTableModelListener(this);
...
}

public void tableChanged(TableModelEvent e) {
int row = e.getFirstRow();
int column = e.getColumn();
TableModel model = (TableModel)e.getSource();
String columnName = model.getColumnName(column);
Object data = model.getValueAt(row, column);

...// Do something with the data...
}
...
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to refresh data of Jtable in java"
Thread Thread Starter Forum Replies Last Post
Problems with multiple threads and GUI refresh in Java Devabrata Software Development 3 30-07-2010 01:24 AM
What is the use of JTable class? Khan Baba Software Development 5 13-02-2010 11:41 AM
Print JTable with the help of java Coldman Software Development 3 25-11-2009 09:02 AM
How to retrieve data from a jTable in Java and MS access Corona Software Development 3 09-07-2009 11:59 AM
Refresh Java Applet Brake Fail Software Development 6 16-03-2009 10:02 PM


All times are GMT +5.5. The time now is 01:33 PM.