开发者

Customizing jTable

I need to customize my jTable. All I need, is to put a custom Swing object (like jButon, jPanel, etc.) into the table cell. Is it possible? I'm trying:

jTable.getModel.setValueAt(jPanel1,0,0)

and

jTable.getModel.setValueAt(jPanel1.getUI(),0,0)

But the result is only a some kind of string, representing the obj开发者_如何学Cect...

I'm aware of custom renderers, but still don't get the technique of registering them properly. How do you do that?


See How to Use Tables, Concepts: Editors and Renderers in the swing tutorial. It sounds like you're getting the default renderer for Object, which is "rendered by a label that displays the object's string value." You can use setDefaultRenderer to associate your class with your renderer, as shown in this example.


You have to make use of a ListCellRenderer for this, Read a similar question here.


you can visit this webpage it's reeeeeeally helpful

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜