I've written an applet which takes input in the form of a boolean function and returns all the possible values in a JTable For example the user enters "x & y" and the output should be: <pre> x y x&y 0 0 0 0 1 0 1 0 0 1 1 1 </pre> The program is all set except that the JTable won't display. When the program first starts it displays an empty 4x4 JTable inside a JScrollPane just fine. To update the table, I've written the following code( where rowData and columnNames are Vectors with the new data for the table and jscrollpane is the JScrollpane that the original empty JTable was displayed in):
Unfortunately the update does not occur. I do receive a very long stack trace for an Exception that is thrown but the Exception does not originate in my applet, it originates in a "java.awt.EventDispatchThread" Any suggestions? I'm stumped!
[This message has been edited by Brian Podolny (edited October 20, 2000).]
Here's the stack trace, I can't figure out that class cast exception. It doesn't seem to originate in my Applet ( named "TruthTableApplet" ). In fact the trace never refers to any method in the Applet itself. What is really puzzling is that if I comment out the code I listed in the original post, This Exception is never generated. Of course, that defeats the entire purpose of the program as the display is never updated. Exception occurred during event dispatching: java.lang.ClassCastException: java.lang.Character at javax.swing.JComponent._paintImmediately(JComponent.java:4352) at javax.swing.JComponent.paintImmediately(JComponent.java:4187) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:205) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154) at java.awt.EventQueue.dispatchEvent(EventQueue.java:317) at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:84) Exception occurred during event dispatching: java.lang.ClassCastException: java.lang.Character at javax.swing.JTable$1.getValueAt(JTable.java:415) at javax.swing.JTable.getValueAt(JTable.java:1711) at javax.swing.JTable.prepareRenderer(JTable.java:3530) at javax.swing.JTable.getToolTipText(JTable.java:2301) at javax.swing.ToolTipManager.mouseEntered(ToolTipManager.java:397) at java.awt.AWTEventMulticaster.mouseEntered(AWTEventMulticaster.java:240) at java.awt.AWTEventMulticaster.mouseEntered(AWTEventMulticaster.java:240) at java.awt.Component.processMouseEvent(Component.java:3726) at java.awt.Component.processEvent(Component.java:3546) at java.awt.Container.processEvent(Container.java:1164) at java.awt.Component.dispatchEventImpl(Component.java:2595) at java.awt.Container.dispatchEventImpl(Container.java:1213) at java.awt.Component.dispatchEvent(Component.java:2499) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451) at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:2318) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2189) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125) at java.awt.Container.dispatchEventImpl(Container.java:1200) at java.awt.Component.dispatchEvent(Component.java:2499) at java.awt.EventQueue.dispatchEvent(EventQueue.java:319) at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
[This message has been edited by Brian Podolny (edited October 21, 2000).]
Hi Brian, I've tried to do the small prototype using ur code. first of all try to run it. -------------------------------
------------------------------ Now from seeing your stack trace what i can guess is that somehow all the elements in one column of your table are not of same type. so check that all the elements in a single column are of same type. regards deekasha
Thanks for your help Deekasha. As to be expected, it was a simple mistake. I mistakenly thought that the constructor taking 2 vectors, takes 2 one-dimensional vectors and split up the elements of the second into rows by dividing its number of elements by the number of columnHeadings. The problem was cleared up by making the rows Vector a two-dimensional Vector where each element is a Vector containing one row of the table. The stack trace makes sense now.
Thanks again, the applet is now working fine. [This message has been edited by Brian Podolny (edited October 23, 2000).]
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop