简体   繁体   中英

Unable to call method in Different class . (Java/GWT)

I am writing a code in GWT client Side. I am getting a error in calling a method in other class. Please see the below code.

        public class QTypeBox extends Composite {
            public FlexTable textTypeFlexTable;

        public QTypeBox() {

            textTypeFlexTable = new FlexTable();
            initWidget(textTypeFlexTable);
            textTypeFlexTable.setSize("520px", "100px");                                
            //addImageTypeBox(0);
            //addTextBox(2);
            //addMatchPairBow(9);

        }

        public int getPosition(){
            int i =textTypeFlexTable.getRowCount();
            return i;
        }       
        public void addImageTypeBox(int i) {
            // TODO Auto-generated method stub
            Image image = new Image((String) null);
            textTypeFlexTable.setWidget(0, 0, image);
        }
         public void addMP(int i){
            Label lblColumnA = new Label("Column A");
            textTypeFlexTable.setWidget(i, 0, lblColumnA);

            Label lblColumnB = new Label("Column B");
            textTypeFlexTable.setWidget(i, 4, lblColumnB);
         }
    }

////

    public class Test extends Composite {

            private FlexTable flexTable_2;

            public Test() {
            initWidget(flexTable_2);


            QTypeBox qTypeBox = new QTypeBox();
            qTypeBox.addMP(4);//**<<<<--------------**


           }

In class Test , where i have marked like <<<<---------- is showing me error.

The method addMP(int) is undefined for the type QTypeBox

I checked the Hint, It asked me to create a method addMP(int) in QtypeBox . If i do this , again it ask me to change the name of Existing method addMP

Can anyone guide where i am doing it wrong.

Your code is clean. The error is due to eclipse not recognizing the class and its methods.

Any one of this steps will resolve your problem

  • Clean Build your project
  • Refresh your project
  • Delete the classes manually and clean build your project
  • Close and open your eclipse If none of the above works then the below one will surely resolve your problem
  • Delete and recreate your classes again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM