Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #349

Some Strange things in JT

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "RC" <rc@THRWHITE.remove-dii-this>
Subject Some Strange things in JT
Message-ID <ela293$lr$4@news.nems.noaa.gov> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 62
Date Wed, 27 Apr 2011 15:27:01 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918021 96.60.20.240 (Wed, 27 Apr 2011 10:27:01 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:27:01 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:349

Show key headers only | View raw


  To: comp.lang.java.gui
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.SINGLE_SELECTION);
dataTable.setRowSelectionAllowed(true);
dataTable.setCellSelectionEnabled(true);
dataTable.setDragEnabled(true);

JScrollPane scroll = new JScrollPane(dataTable);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.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!

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

Some Strange things in JT "RC" <rc@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
  Re: Some Strange things i "Douwe" <douwe@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000

csiph-web