Results 1 to 2 of 2

Thread: How to refresh data of Jtable in java

  1. #1
    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

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    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...
    }
    ...
    }

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,980,584.38811 seconds with 17 queries