Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public class TableCellTextRenderer {
  2.  
  3. @Override
  4. public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
  5. boolean hasFocus, int row, int column) {
  6.  
  7. final JTextPane jtextPane = new JTextPane();
  8. JScrollPane scrollPane = new JScrollPane(jtextPane);
  9. scrollPane.setPreferredSize(new Dimension(350,350));
  10. scrollPane.setVisible(true);
  11. jtextPane.setEditable(false);
  12. jtextPane.setAutoscrolls(true);
  13. jtextPane.setContentType("text/html");
  14. jtextPane.setText(myHtmlText);
  15. jtextPane.setVisible(true);
  16. jtextPane.setPreferredSize(new Dimension(350,350));
  17.  
  18. //this setViewPort has no effect
  19. scrollPane.setViewportView(jtextPane);
  20.  
  21. jtextPane.setVisible(true);
  22. scrollPane.setAutoscrolls(true);
  23. scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  24. scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  25.  
  26. JPanel jpanel = new JPanel();
  27. jpanel.setVisible(true);
  28. jpanel.setPreferredSize(new Dimension(360, 360));
  29. jpanel.add(scrollPane);
  30.  
  31. return jpanel;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement