you can typecast *MyMenuBar *to *MenuBar *but not the other way round. Here
you are trying to typecast *MenuBar* to *MyMenuBar*.

On 19 October 2010 21:28, alexoffspring <[email protected]> wrote:

> Thanks guys.
>
> Ok, i got the error in the constructor. Now it sounds like this:
>
> > public class MyMenuBar extends MenuBar {
>
> // super constructor
> public MyMenuBar(boolean bool) {
>          super(bool);
> } ;
>
>
>
> But still i got the same ClassCastException.
>
> root    is a MenuItem   and    root.getSubMenu() return a MenuBar
> object.
>
>
>
>
> On 19 Ott, 17:39, ep <[email protected]> wrote:
> > where do you make new MyMenuBar() and how do you provide it to the
> > "root" member? and what type is root actually?
> >
> > On 19 Okt., 17:14, alexoffspring <[email protected]> wrote:
> >
> >
> >
> > > I created a public class MyMenuBar   just to use the getItems()
> > > method, which is protected in MenuBar:
> > > ........
> > > public class MyMenuBar extends MenuBar {
> >
> > >         // super constructor
> > >         public MyMenuBar(boolean bool) {
> > >                 new MenuBar(bool);
> > >         }
> >
> > >         // the super.getItems() is protected
> > >         public List<MenuItem> getItems() {
> > >                 return super.getItems();
> > >         }
> >
> > > };
> >
> > > ........
> >
> > > I don't understand why a get a   java.lang.ClassCastException  when i
> > > try to cast a MenuBar into a MyMenuBar:
> >
> > > .........
> > > MenuBar menuBar = root.getSubMenu();
> > > local_mmb = ((MyMenuBar) menuBar).getItems();
> > > ........
> >
> > > Where am i wrong?- Nascondi testo citato
> >
> > - Mostra testo citato -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>


-- 
Prashant
www.claymus.com
code.google.com/p/claymus/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to