java.lang.ClassCastException: java.lang.String cannot be cast to com.jason.test.tableheaders.MyColumnObject

Coderanch | Jason Richard | 3 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    How to use a custom Object for a header

    Coderanch | 3 years ago | Jason Richard
    java.lang.ClassCastException: java.lang.String cannot be cast to com.jason.test.tableheaders.MyColumnObject

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.lang.String cannot be cast to com.jason.test.tableheaders.MyColumnObject

      at com.jason.test.tableheaders.DefaultTestCellRenderer.getTableCellRendererComponent()
    2. com.jason.test
      DefaultTestCellRenderer.getTableCellRendererComponent
      1. com.jason.test.tableheaders.DefaultTestCellRenderer.getTableCellRendererComponent(DefaultTestCellRenderer.java:27)
      1 frame
    3. Java RT
      Window.pack
      1. javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer(Unknown Source)
      2. javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight(Unknown Source)
      3. javax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize(Unknown Source)
      4. javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(Unknown Source)
      5. javax.swing.JComponent.getPreferredSize(Unknown Source)
      6. javax.swing.ViewportLayout.preferredLayoutSize(Unknown Source)
      7. java.awt.Container.preferredSize(Unknown Source)
      8. java.awt.Container.getPreferredSize(Unknown Source)
      9. javax.swing.JComponent.getPreferredSize(Unknown Source)
      10. javax.swing.ScrollPaneLayout.preferredLayoutSize(Unknown Source)
      11. java.awt.Container.preferredSize(Unknown Source)
      12. java.awt.Container.getPreferredSize(Unknown Source)
      13. javax.swing.JComponent.getPreferredSize(Unknown Source)
      14. java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
      15. java.awt.Container.preferredSize(Unknown Source)
      16. java.awt.Container.getPreferredSize(Unknown Source)
      17. javax.swing.JComponent.getPreferredSize(Unknown Source)
      18. java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
      19. java.awt.Container.preferredSize(Unknown Source)
      20. java.awt.Container.getPreferredSize(Unknown Source)
      21. javax.swing.JComponent.getPreferredSize(Unknown Source)
      22. javax.swing.JRootPane$RootLayout.preferredLayoutSize(Unknown Source)
      23. java.awt.Container.preferredSize(Unknown Source)
      24. java.awt.Container.getPreferredSize(Unknown Source)
      25. javax.swing.JComponent.getPreferredSize(Unknown Source)
      26. java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
      27. java.awt.Container.preferredSize(Unknown Source)
      28. java.awt.Container.getPreferredSize(Unknown Source)
      29. java.awt.Window.pack(Unknown Source)
      29 frames
    4. com.jason.test
      HeaderTester.main
      1. com.jason.test.tableheaders.HeaderTester.main(HeaderTester.java:31)
      1 frame