Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ClassCastException on Boolean Table cell...

0 views
Skip to first unread message

Dag Sunde

unread,
Sep 30, 2004, 3:44:28 PM9/30/04
to
I have a JTable with the following model:
private Object rows[][] = {
{new Boolean(false), "", "", "", "", "", "", "", "", "", "", ""},
{new Boolean(false), "", "", "", "", "", "", "", "", "", "", ""},
{new Boolean(false), "", "", "", "", "", "", "", "", "", "", ""}};

The table displays as expected, and renders the first columns
as checkboxes. But as soon as I click on the first checkbox, the following
exception occurs:

java.lang.ClassCastException
at
javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(JTable.java
:3401)
at javax.swing.JTable.prepareRenderer(JTable.java:3693)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4771)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4724)
at javax.swing.JComponent._paintImmediately(JComponent.java:4668)
at javax.swing.JComponent.paintImmediately(JComponent.java:4477)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQu
eueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:197)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

After I have clicked on a checkbox once, this exception is thrown whatever i
do
in the table...

Any hints or obvious pitfalls I should be aware of?
I have tried to explicitly set the colums editor & renderer to JCheckbox,
too...

--
Dag
58°26'15.9" N 008°46'45.5" E


Paul Lutus

unread,
Sep 30, 2004, 4:37:39 PM9/30/04
to
Dag Sunde wrote:

> I have a JTable with the following model:

/ ...

> Any hints or obvious pitfalls I should be aware of?

Just one. Avoid asking questions that include error stack dumps but that
don't include the relevant code.

> I have tried to explicitly set the colums editor & renderer to JCheckbox,
> too...

I'll bet if you submit your post to your Java compiler, it just won't know
what to do. Same here.

--
Paul Lutus
http://www.arachnoid.com

Dag Sunde

unread,
Sep 30, 2004, 8:40:52 PM9/30/04
to
"Paul Lutus" <nos...@nosite.zzz> wrote in message
news:10lorkk...@corp.supernews.com...

> Dag Sunde wrote:
>
> > I have a JTable with the following model:
>
> / ...
>
> > Any hints or obvious pitfalls I should be aware of?
>
> Just one. Avoid asking questions that include error stack dumps but that
> don't include the relevant code.
>

Usually I do agree with you, and I try to introduce my friends over
at c.l.b.v.m to Andrew Thompson's principle about "SSCCE":
(http://www.physci.org/codes/sscce.jsp#eg)

But sometimes it must be allowed to throw out a question about
a specific error without a compileable sample that reproduces
the error, in case somebody can make an educated guess based
on experience.

I know the chances of getting help is drastically reduced, but
that is a factor I'm willing to live with.

(Especially when the error suddenly appears in 6 months old code,
and its 4 hour to the next deadline) ...

:-)

Paul Lutus

unread,
Oct 1, 2004, 12:17:39 AM10/1/04
to
Dag Sunde wrote:

We promise to equal your diligence and attention to detail.

Tor Iver Wilhelmsen

unread,
Oct 1, 2004, 3:18:06 AM10/1/04
to
"Dag Sunde" <d...@orion.no-way> writes:

> Any hints or obvious pitfalls I should be aware of?
> I have tried to explicitly set the colums editor & renderer to JCheckbox,
> too...

What does getColumnClass() return? Do you have a custom setValueAt()?
Or getValueAt()? There is so much that could affect this IN THE CODE
YOU DID NOT POST so it's hard to answer.

Dag Sunde

unread,
Oct 1, 2004, 3:47:17 AM10/1/04
to
"Tor Iver Wilhelmsen" <tor.iver....@broadpark.no> wrote in message
news:ubrfmo...@broadpark.no...

Yes I have an custom setValueAt(), and the error was buried there.

It was a
rows[r][c] = value.toString();

on a column that should have been:
rows[r][c] = value;


Thanks!

0 new messages