将广播组放入JTable [英] putting radio group into JTable

查看:56
本文介绍了将广播组放入JTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎JTable只能允许复选框.如何将无线电组放入JTable的单元中?

it seems JTable can only allow checkbox. how can i put a radio group into a cell on the JTable?

推荐答案

您的问题很短,因此我可能会误解,但无论如何 默认情况下,布尔值已在jtable中注册,以通过复选框呈现/编辑.

your question is quite short, so i could have misinterpreted, but anyway A Boolean is by default registered with the jtable to be rendered/edited by a checkbox.

根据单元格的数据类型,在绘制单元格时会检索渲染器/编辑器. 您可以在包含两个单选按钮的JPanel上建立编辑器/渲染器,这些单选按钮使用ButtonGroup分组. 根据要在数据模型中存储的数据,您有各种选择. 例如,如果您的数据模型包含整数,则新的编辑器/渲染器应该可以使用它.

Depending on the cells'datatype the renderer/editor are retrieved when painting the cells. you could base a editor/renderer on a JPanel containing two radiobuttons which are grouped using a ButtonGroup. Depending on what data you want to store in the datamodel, you have various choices. if for example your datamodel contains ints, then your new editor/renderer should be able to work with that.

这篇关于将广播组放入JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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