Article View: borland.public.jbuilder.java.swing
Article #9992Re: JTable - Input from Multiple Choice
From: Remon Huijts
Date: Wed, 08 Dec 1999 00:00
Date: Wed, 08 Dec 1999 00:00
25 lines
1654 bytes
1654 bytes
>The effect I'm after is that when they tab into a cell in this column, >instead of the normal edit mode they'd see a drop-down list with the >allowable values. ... >It should be possible to do by creating a special TableCellEditor derived >from Choice, but being such a basic grid operation, I was hoping there might >be a simpler standard way to say "this string array contains the options for >this column". Could this perhaps be your simple standard way? JComboBox myComboBox = new JComboBox(myAllowableValuesArray); TableColumn myColumn = myTable.getColumnModel().getColumn(myColumnIndex); myColumn.setCellEditor(new DefaultCellEditor(myComboBox); Why does this work? DefaultCellEditor implements the TableCellEditor interface for you and provides constructors for setting a JTextField, a JCheckBox or a JComboBox to be the editing component. For other editors however, you still need to create a subclass that implements the TableCellEditor interface.
Technical Details
Message-ID:
<82kbon$4nk$1@news.worldonline.nl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<oJ314.326$gb7.5032@ozemail.com.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,d7246a656f18280b X-Google-Attributes: gid111d45,public From: "Remon Huijts" <pirore@tip.nl> Subject: Re: JTable - Input from Multiple Choice Date: 1999/12/08 Message-ID: <82kbon$4nk$1@news.worldonline.nl> X-Deja-AN: 558265402 References: <oJ314.326$gb7.5032@ozemail.com.au> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: newsmaster@worldonline.nl X-Trace: news.worldonline.nl 944616023 4852 195.241.234.120 (8 Dec 1999 01:20:23 GMT) Organization: WorldOnline News server NNTP-Posting-Date: 8 Dec 1999 01:20:23 GMT Newsgroups: borland.public.jbuilder.java.swing