Jtable add rows to top instead of bottom

A

andrina.luczon

I'm creating an error/warning message table. Every time an error or
warning is generated, the row count increases by one and the value of
the newly added row value is set to the message.

However, when the new row is added, it is added to the bottom of the
list. The user is not aware that a new message is added unless they
scroll down to the bottom of the table.

Is there a way to add new rows to the top of the table (without doing
tons of shifting)

Or is there a way to set the focus to bottom of the table, so that if
more rows are added, the scroll will automatically scroll down to the
most recently added row?

Hope that makes sense.... any help is appreciated.
 
A

Andrey Kuznetsov

I'm creating an error/warning message table. Every time an error or
warning is generated, the row count increases by one and the value of
the newly added row value is set to the message.

However, when the new row is added, it is added to the bottom of the
list. The user is not aware that a new message is added unless they
scroll down to the bottom of the table.

DefaultTableModel#insertRow(int row, Object [] rowdata);

Andrey
 
L

Lionel

I'm creating an error/warning message table. Every time an error or
warning is generated, the row count increases by one and the value of
the newly added row value is set to the message.

However, when the new row is added, it is added to the bottom of the
list. The user is not aware that a new message is added unless they
scroll down to the bottom of the table.

Is there a way to add new rows to the top of the table (without doing
tons of shifting)

Or is there a way to set the focus to bottom of the table, so that if
more rows are added, the scroll will automatically scroll down to the
most recently added row?

Hope that makes sense.... any help is appreciated.

If you have some sensible order then you might consider looking at
extending AbstractTableModel. It makes life much easier.

Lionel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top