Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » CastException for TableTreeItem
CastException for TableTreeItem [message #371050] Tue, 17 June 2003 10:46 Go to next message
Eclipse UserFriend
Hi folks,

I get an error (under Win2K) when I want to cast the following:

public class MyItem extends TableTreeItem {
...
}

MyItem[] items = (MyItem[]) tableTree.getSelection();

getSelection will always return MyItems so I don't understand why there
is an exception thrown.
It seems to be more complicated because of if I do the following nothing
is thrown:

TableTreeItem[] items = tableTree.getSelection();
if (items.length == 1)
MyItem item = (MyItem) items[0];


Thanks in advance
Ralf
Re: CastException for TableTreeItem [message #371051 is a reply to message #371050] Tue, 17 June 2003 11:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NOSPAM.us.ibm.com

I would imagine it is because the array returned from getSelection() is
of type TableTreeItem[] and not MyItem[]. The only way it could be
TabeTreeITem[] is if you overrode getSelection() to return that.

Just because all of the items in an array may be of type MyItem, that
doesn't make the array to be of type MyItem[]. The type of array is
determined before any items are placed into it. It is determined when it
is created.

Rich
Re: CastException for TableTreeItem [message #371053 is a reply to message #371051] Tue, 17 June 2003 11:25 Go to previous message
Eclipse UserFriend
Hello Richard,

thank you very much. I understand now.

Ralf

Richard L. Kulp schrieb:
> I would imagine it is because the array returned from getSelection() is
> of type TableTreeItem[] and not MyItem[]. The only way it could be
> TabeTreeITem[] is if you overrode getSelection() to return that.
>
> Just because all of the items in an array may be of type MyItem, that
> doesn't make the array to be of type MyItem[]. The type of array is
> determined before any items are placed into it. It is determined when it
> is created.
>
> Rich
>
Previous Topic:Modality problem in gtk
Next Topic:Coolbar with Combo
Goto Forum:
  


Current Time: Thu Nov 06 15:13:33 EST 2025

Powered by FUDForum. Page generated in 0.03027 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top