Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Some Strange things in JTable

Reply
Thread Tools

Some Strange things in JTable

 
 
RC
Guest
Posts: n/a
 
      12-07-2006
I am try to create a dynamic table.

String[] dataColumns = {"Observation Time", "Value", "Mode"};

DefaultTableModel dataTableModel =
new DefaultTableModel(dataColumns, 100);

// read data into dataTableModel here
// each row is a vector,
// read in another vector for Timestamp, Double and String

JTable dataTable = new JTable(dataTableModel);
dataTable.setSelectionMode(ListSelectionModel.SING LE_SELECTION);
dataTable.setRowSelectionAllowed(true);
dataTable.setCellSelectionEnabled(true);
dataTable.setDragEnabled(true);

JScrollPane scroll = new JScrollPane(dataTable);
scroll.setVerticalScrollBarPolicy(ScrollPaneConsta nts.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.setHorizontalScrollBarPolicy(ScrollPaneCons tants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setWheelScrollingEnabled(true);

So far so good, everything is working fine.
I can select a row by single click,
select a cell by double clicks,
edit a cell, scroll up and down.

Later I have new data coming, I remove all rows from that
dataTableModel, and read the new data and added to new row to
that dataTableModel. Then I got new data display on the JTable.

So far still in good shape. However, here are the problems I found:

1. I can't select a row any more.
2. I can't edit the a table cell any more.
3. the scroll bar is goen, I can only see a portion of table. I can't
scroll up and down, left and right.

I can still do drag and select table cell by double clicks.
So I can only do select a row by dragging.

Can anyone out there explain or tell me why?

Each time I added a new row, I do

dataTableModel.addRow(vectorRow);
dataTableModel.fireTableDataChanged();

and after I finished added all rows, I do

dataTableModel.fireTableChanged(new TableModelEvent(dataTableModel));

But still no luck at all!
Any idea? Please tell me how to fixed above three problems?

Thank Q very much in advance!
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      12-08-2006
RC wrote:
> I am try ..


...to make enemies through your consistent use of multi-posting?

Please refrain from multi-posting.

(X-post to c.l.j.p/h., w/ f-u to c.l.j.h. only)

Andrew T.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
vs2005 publish website doing bad things, bad things =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?= ASP .Net 1 10-25-2006 06:18 PM
IIS Security strange things Alexey Smirnov ASP .Net 4 03-03-2004 07:48 AM
D100 in Scotland - 10 random things I learned (some OT, some rant) mikey2 Digital Photography 6 09-09-2003 05:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57