简体   繁体   English

使用HTML呈现将滚动条添加到JTable单元格

[英]Adding Scrollbar to JTable cell with HTML rendering

I want to add scroll bar to a cell in JTable which has HTML contents that needs to be rendered. 我想将滚动条添加到JTable中具有需要呈现的HTML内容的单元格中。 Tried creating a custom cell renderer with following code snap. 尝试使用以下代码捕捉创建自定义单元格渲染器。 Scroll bar appears in the cell however I am unable to scroll. 滚动条出现在单元格中,但是我无法滚动。

public Component getTableCellRendererComponent( JTable table,
                Object value, boolean isSelected, boolean hasFocus,
                int row, int column )
    {
          theLabel.setText((String)value);
         JScrollPane thePane = new JScrollPane(theLabel);
         return thePane;
    }

Any clues will be appreciated 任何线索将不胜感激

Thanks for comments in this question, realized this problem needs a combination of TableCellEditor and TableCellRenderer. 感谢您对此问题的评论,意识到此问题需要TableCellEditor和TableCellRenderer的组合。 Could resolve this issue with both editor and renderer. 可以使用编辑器和渲染器解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM