Article View: borland.public.jbuilder.java.swing
Article #9589A customized TableCellEditor in a JTable does not work!
From: Martin Dahlem
Date: Thu, 02 Mar 2000 00:00
Date: Thu, 02 Mar 2000 00:00
36 lines
1965 bytes
1965 bytes
Dear all,
I want to validate user-inputs in
a JTable. When I set a new TableCellEditor
to any column, it is used only when I doubleclick
in the cell. Then it works fine so far.
Otherwise (setting the focus to the cell
by using the TAB-key or by clicking only once in it)
my cellEditor is not used for this cell and
the user can type all the invalid characters
my cellEditor should filter out.
If I use
"cellEditor.setClickCountToStart(0);",
I make my cellEditor work after a single click
in the cell. But how can I make it work after
setting the focus to a cell by using the TAB-key????
Thank you for any tip or hint!
Here is my example:
Vector data = new Vector();
Vector columNames = new Vector();
columNames.addElement("Connection");
columNames.addElement("AsId");
JTable tableAsIds = new JTable();
tableAsIds.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tableAsIds.setModel(new DefaultTableModel(data, columNames));
JScrollPane tableScroller = new JScrollPane(tableAsIds);
add(tableScroller);
JTextField tf = new JTextField();
tf.addKeyListener(new NumberValidator());
DefaultCellEditor cellEditor = new DefaultCellEditor(tf);
cellEditor.setClickCountToStart(0);
tableAsIds.getColumnModel().getColumn(1).setCellEditor(cellEditor);
Technical Details
Message-ID:
<38BE5FF0.AA2904CD@germany.ncr.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,6edbc71d4b1ba6ae,start X-Google-Attributes: gid111d45,public From: Martin Dahlem <martin.dahlem@germany.ncr.com> Subject: A customized TableCellEditor in a JTable does not work! Date: 2000/03/02 Message-ID: <38BE5FF0.AA2904CD@germany.ncr.com> X-Deja-AN: 592200404 Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: ncrnews.daytonoh.ncr.com X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 2 Mar 2000 04:29:13 -0800, 192.127.94.7 MIME-Version: 1.0 Reply-To: martin.dahlem@germany.ncr.com Newsgroups: borland.public.jbuilder.java.swing