简体   繁体   English

特定JTable单元格中的JComboBox

[英]JComboBox in specific JTable cell

I've a problem that is driving me crazy. 我有一个问题使我发疯。

I have a classic JTable, with several columns. 我有一个经典的JTable,有几列。 I need that a particular column, instead of simple texts values in its cell, it must contain a ComboBox. 我需要一个特定的列,而不是其单元格中的简单文本值,它必须包含一个ComboBox。 I searched A LOT, all I found was examples that would implement the same JComboBox in each cell of the column, that it's not what I need: I need that each cell of the column has a combo box with different values. 我搜索了很多,发现的例子都是可以在该列的每个单元格中实现相同的JComboBox的示例,这不是我所需要的:我需要该列的每个单元格都有一个具有不同值的组合框。

Can anyone give me some practical example of how to do it, please? 有人可以给我一些实际的例子吗?

Thanks. 谢谢。

PS: I'm using NetBeans. PS:我正在使用NetBeans。

The TableCellEditor.getTableCellEditorComponent() method takes a row as argument. TableCellEditor.getTableCellEditorComponent()方法将一行作为参数。 Use the existing example as a guide, and use the row argument of this method to decide which values must be proposed by the combo box. 使用现有示例作为指南,并使用此方法的row参数来确定组合框必须建议的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM