如何将下拉菜单添加到JTable单元格 [英] How to add a drop down menu to a JTable cell

查看:532
本文介绍了如何将下拉菜单添加到JTable单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是之前提出的问题。我在帖子之前搜索了很多,但是找不到任何可接受的。

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的 DefaultCellEditor对于JTable ,如果所有 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 for JComboBoxes with custom AbstractTableModel

      这篇关于如何将下拉菜单添加到JTable单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆