5 Replies Latest reply: Dec 24, 2012 2:32 AM by 980759 RSS

    I need help with what I believe to by a syntax error.

    978884
      The following snippet is from a class that extends AbstractTableModel.

      dataSource is an ArrayList, containing instances of a class for which getDescription() is a valid method.

      Line six is giving me an error. Maybe someone can tell me how to do this properly.

      Aside from that, I do have more code to insert. I just want to get this part right before adding the rest.

      @Override
      public Object getValueAt(int rowIndex, int columnIndex) {
      Object budgetDatum = null;
      switch(columnIndex){
      case 0:
      budgetDatum = dataSource.get(rowIndex).getDescription();
      }
      return budgetDatum;
      }
        • 1. Re: I need help with what I believe to by a syntax error.
          EJP
          Which is line six, and what error is it giving you? And how exactly do you expect to get help when you don't provide all the relevant information?
          • 2. Re: I need help with what I believe to by a syntax error.
            978884
            By line six, I am referring to the following, which is the sixth line of my code:

            budgetDatum = dataSource.get(rowIndex).getDescription();

            The method, "getDescription()", is not recognized as a valid method, which leads me to believe I am accessing the member of dataSource incorrectly.
            • 3. Re: I need help with what I believe to by a syntax error.
              rp0428
              >
              By line six, I am referring to the following, which is the sixth line of my code:

              budgetDatum = dataSource.get(rowIndex).getDescription();

              The method, "getDescription()", is not recognized as a valid method, which leads me to believe I am accessing the member of dataSource incorrectly.
              >
              You still aren't providing all of the information needed.

              What type of object does 'dataSource.get' return?

              You probably need to cast the object to the proper type and call 'getDescription on that type.
              If it returns a BudgetDatum class object then cast it as that
              BudgetDatum budgetDatum;
              . . .
              budgetDatum = ((BudgetDatum) dataSource.get(rowIndex)).getDescription();
              If you aren't using generics the 'get' method is probably just returning an Object.
              • 4. Re: I need help with what I believe to by a syntax error.
                EJP
                what I believe to be a syntax error
                which leads me to believe I am accessing the member of dataSource incorrectly.
                There is too much here about what you believe, and not enough about what the compiler actually told you. If it was a syntax error the compiler would have said so, and if all your beliefs were correct you wouldn't be asking the question.
                • 5. Re: I need help with what I believe to by a syntax error.
                  980759
                  and the data type is compatibale with getValue method and setValue method

                  what are doing with the below method?
                  public Class getColumnClass(int c) {             return getValueAt(0, c).getClass();         }