如何将JComboBox添加到JTable单元格? [英] How to add a JComboBox to a JTable cell?

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

问题描述

我正在尝试将JComponents添加到JTable Cells。我是否实现了CellRenderer或CellEditor?

I am trying to add JComponents to JTable Cells. Do I Implement CellRenderer or CellEditor?

推荐答案

您需要的是一个自定义编辑器,它将返回JComboBox(或您想要的任何组件)使用)。您应该查看 JTable的Sun教程,它包含一个如何使用JComboBox作为编辑器的示例。如果你想将JComboBox用作渲染器,那么教程也适用于此。

What you need is a custom editor which will return the JComboBox (or whatever component you want to use). You should check the Sun tutorial for JTable, it contains an example on how to use a JComboBox as an editor. If you want to use JComboBox as a renderer as well, the tutorial applies to that too.

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

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