如何将JLabel []添加到JTable? [英] How do I add a JLabel[] to a JTable?
本文介绍了如何将JLabel []添加到JTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要添加到JTable的JLabel数组.我尝试使用
I have an array of JLabels which I want to add to a JTable. I tried using
myJTable.add(myJLabelArray);
希望它可以工作,但不能(显然,否则我不会在这里).
Hoping it would work, but it doesn't (Obviously, otherwise I wouldn't be here).
有人可以帮忙吗?
推荐答案
Using add method is not the way to add components to a JTable
. Components should never be added directly to a JTable
or its TableModel
.
JLabels
只是用于显示文本的Swing组件.
JLabels
are just Swing components that render text.
您可以使用TableCellRenderer
.看看编辑器&渲染器
这篇关于如何将JLabel []添加到JTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文