Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Posts
    38
    Rep Power
    0

    Thumbs up incompatible types error..

    Hi Friends.

    XML Code:
    public int findMenuCheckBox( String s )  
      {  
        int match = -1;      
        for( int i = 0; i < windowMenu.getItemCount(); ++i )  
        {  
          mi = windowMenu.getItem( i );  
          if( mi instanceof JCheckBoxMenuItem )  
          {  
            if( ((JCheckBoxMenuItem)mi).getText().equals( s ) )  
            {  
              match = i;  
              break;  
            }  
          }       
        }  
        return( match );  
      }
    Here mi is JCheckBoxMenuItem.
    I m getting this error

    Java Code:
    incompatible types
    
    found   : javax.swing.JMenuItem
    required: javax.swing.JCheckBoxMenuItem
          mi = windowMenu.getItem( i );  
                                 ^
    1 error

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: incompatible types error..

    Assuming windowMenu is a JMenu, see the API for getItem - it returns a JMenuItem, not a JCheckBoxMenuItem. And for future reference, if you want help sooner you should be a lot more specific about the context of your post (case in point: I'm guessing that windowMenu is a JMenu - you made NO mention of its data type)

Similar Threads

  1. incompatible types
    By angelicatomnob in forum New To Java
    Replies: 3
    Last Post: 01-17-2012, 04:25 PM
  2. incompatible types!!
    By sneha343 in forum New To Java
    Replies: 7
    Last Post: 12-01-2011, 12:49 AM
  3. incompatible types error
    By magic in forum New To Java
    Replies: 3
    Last Post: 06-02-2010, 05:58 PM
  4. Replies: 1
    Last Post: 03-10-2010, 02:53 PM
  5. Replies: 6
    Last Post: 10-08-2008, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •