问题描述
这可能是之前提出的问题。我在帖子之前搜索了很多,但是找不到任何可接受的。
This may be a question asked before. I searched a lot before posting here, but couldn't figure out any acceptable one.
有人可以告诉我如何做到这一点。我只需要在单击单元格时获得一个下拉菜单,这样我就必须从中选择一个值(作为限制用户选择的方式)。
Can some one show me a way how to do this. I simply need to get a drop down menu when i click on the cell so that I'll have to select a value from that (as a way to restrict the user selection).
如果有人可以提供帮助,我相信它会帮助很多人。有很多类似的问题,但没有任何明确的答案。请回答一下细节。一个例子将非常感谢..
If some one can help with this I believe it will help a lot of people out there. There are a lots of questions similar to this but no any clear answer. Please answer with a bit more details. An example would be much appreciated..
谢谢!
推荐答案
-
使用带有DefaultTableModel的,如果所有
JComboBoxes
在具体的TableColumn中具有相同的值use DefaultCellEditor with DefaultTableModel for JTable in the event that all the
JComboBoxes
will have identical values in the concrete TableColumn如果没有相同的值,则使用
DefaultCellEditor
为JComboBoxes
使用自定义AbstractTableModel
if will have not identical values, then to use
DefaultCellEditor
forJComboBoxes
with customAbstractTableModel
这篇关于如何将下拉菜单添加到JTable单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!