Article View: borland.public.jbuilder.java.swing
Article #10000Re: JTable - Input from Multiple Choice
From: Yael Raz
Date: Thu, 09 Dec 1999 00:00
Date: Thu, 09 Dec 1999 00:00
49 lines
2542 bytes
2542 bytes
Thank you! This is much more straightforward. However, there's a problem: For some reason, when the combo box appears in the cell and I click the drop-down button, the list only displays for the lower rows in the table. The rule seems to be that unless the combo-box drop-down list hangs outside the application frame - it doesn't show. I can demonstrate it by dropping down the list in a lower cell (where it shows), then stretching down the application frame and clicking the combo box again - this time the list doesn't appear. Is this a bug? I got the same problem when I used my own TableCellEditor, and assumed I was doing something wrong. But now I've replaced it with your 3-line solution, the problem is still there. Thanks again, Yael. Remon Huijts wrote in message <82kbon$4nk$1@news.worldonline.nl>... >>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:
<k7I34.953$_H3.2644@ozemail.com.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<oJ314.326$gb7.5032@ozemail.com.au> <82kbon$4nk$1@news.worldonline.nl>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,d7246a656f18280b X-Google-Attributes: gid111d45,public From: "Yael Raz" <yaelr@locus.com.au> Subject: Re: JTable - Input from Multiple Choice Date: 1999/12/09 Message-ID: <k7I34.953$_H3.2644@ozemail.com.au> X-Deja-AN: 558454399 Distribution: world References: <oJ314.326$gb7.5032@ozemail.com.au> <82kbon$4nk$1@news.worldonline.nl> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0 X-Trace: ozemail.com.au 944721488 203.108.34.232 (Thu, 09 Dec 1999 17:38:08 EST) Organization: OzEmail Ltd, Australia NNTP-Posting-Date: Thu, 09 Dec 1999 17:38:08 EST Newsgroups: borland.public.jbuilder.java.swing