JTable combobox editor

A

awvvo

I have a JTable with 17 columns. The last 15 columns contain airport
codes (this is used
for entering a flight schedule). The application uses a list of 5000
airport codes.

When I do:
column.setCellEditor(new MyComboBoxEditor(airportValues));

for each column it is very slow.

Is it possible to only use 1 combobox and reuse and activate it as a
celleditor when I click on a particular cell?

Can someone give me a hint how to do this?

regards
john
 
Z

zero

(e-mail address removed) wrote in @g44g2000cwa.googlegroups.com:
I have a JTable with 17 columns. The last 15 columns contain airport
codes (this is used
for entering a flight schedule). The application uses a list of 5000
airport codes.

When I do:
column.setCellEditor(new MyComboBoxEditor(airportValues));

for each column it is very slow.

Is it possible to only use 1 combobox and reuse and activate it as a
celleditor when I click on a particular cell?

Can someone give me a hint how to do this?

regards
john

I assume MyComboBoxEditor extends TableCellEditor?

Subclass the JTable and override the TableCellEditor getCellEditor(int
row, int column) method. Like this:

public class MyJTable extends JTable
{
private MyComboBoxEditor comboEditor =
new MyComboBoxEditor(airportValues);

// ...

public TableCellEditor getCellEditor(int row, int column)
{
if(column > 2)
{
// if necessary, change the comboEditor values
return comboEditor;
}

return super.getTableCellEditor(row, column);
}
}

Customize to suit your needs.

zero
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top