Link to home
Start Free TrialLog in
Avatar of miraodb
miraodb

asked on

GetColumnCount() deprecated, can't resolve method !

hi everyone,

i have a small problem here,

when i try to use the getColumnCount() function it says that it can't resolve it:

GXML.java [50:1] cannot resolve symbol
symbol  : method getColumnCount ()
location: class GXML
            int nCols = getColumnCount();

i of course have the following import:
import javax.swing.table.*;
 which is suppose to contains this function.

any idea ??

thankx in advance.

miraodb
Avatar of Nick_72
Nick_72

you didn't specify the table did you?

int nCols = getColumnCount();

---

int nCols = theTable.getColumnCount();
Avatar of zzynx
That's exactly what I meant with my comment in the original (already closed) Q.
Avatar of miraodb

ASKER

no i didn't but i took this code sample form another one whihc works fine, here follows the sample which works:

public String getStartHTML()
{
      String sBuffer = "";
      sBuffer += "<table border='1' bordercolor='#666666' cellspacing='0' Cellpadding='5'>\n";
        sBuffer += "<tr bgcolor='#DDDDDD'>\n";
      int nCols = getColumnCount();
      for (int col = 0; col < nCols; col++) // physical columns
      {
            String title = getColumnTitle(col);
            sBuffer += "<td><div align='center'>";
            sBuffer += title != null ? ClassUtils.replaceNewLinesWithHtml(title) : "";
            sBuffer += "</div></td> ";
      }
        sBuffer += "</tr>\n";
      return sBuffer;
}
And that getStartHTML() function is a member of what class?
Does that class have a getColumnCount() function?
Check if that class perhaps extends JTable.
You can't call functions in the void. They must be defined in some class.
Avatar of miraodb

ASKER

there is in fact a definition of this function another class but i don't understand what it does.

public int getColumnCount()
{
        if(m_b2dDrilldownOn)
            return super.getColumnCount();
        else
            return m_VisibleFields.size() + (m_SyntheticFields != null ? m_SyntheticFields.length : 0);
}
Well, this
>> super.getColumnCount();
indicates that the class you copied it from extends a JTable (or another class that has a getColumnCount() function)
Anyway, you want that call to return you the columns of a table?

Why don't you just call getColumnCount() on that jTable object?
Avatar of miraodb

ASKER

ok, sorry for late answer, but actually it's not that easy, i need to parse data from an application and then parse it adn create an XLM fiel with it.

the thing is that i have to use many of function that are included in differents classes (create for the application).
so i guess i should extends my class to one of the other and i tried like that :
public abstract class GXML extends TableViewPanel

but i get this error:
GXML.java [31:1] cannot access TableViewPanel
bad class file: C:\perso\work\java extract from classes\TableViewPanel.java
file does not contain class TableViewPanel
Please remove or make sure it appears in the correct subdirectory of the classpath.
public abstract class GXML extends TableViewPanel {
                                   ^
1 error
Errors compiling GXML.

any idea?
What is TableViewPanel?
What do you import in your code so it "knows" TableViewPanel?
Avatar of miraodb

ASKER

TableViewPanel  is the class that as most of the function i need, but it also extends another one that contains some other functions.

i import all the classes from the jar.
ok i have a jar file that contains all the classes under a folder
looks like something like that:
folder.subfolders.classes (here is TableViewPanel)

so i have import for expample:


import main.dataview.*; where TableViewPanel is a class of dataview
Avatar of miraodb

ASKER

actually i messed up.
now i got it. i've done the
package main.toolkit.dataviewer; which contains what i want but i have this error:

GXML.java [33:1] cannot resolve symbol
symbol  : constructor TableViewPanel ()
location: class main.toolkit.dataviewer.TableViewPanel
public abstract class GXML extends TableViewPanel {

what's wonrg?
That means that TableViewPanel doesn't have a constructor without arguments,
while you try to use it like that (I mean wihtout parameters)
Can you post that GXML code again? (And indicate where the error occurs?)
... and maybe slightly increment the points of this Q?
;)
Avatar of miraodb

ASKER

hope that's better man ;)
anyway, this java thing dirves me crazy.
here is the code:

package axiomsl.toolkit.dataviewer;

import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.util.*;
import java.text.*;
import java.io.*;
import java.net.*;
import java.awt.datatransfer.*;

import javax.swing.*;
import javax.swing.table.*;

import com.f1j.swing.*;
import com.f1j.ss.*;
import com.f1j.util.*;

import axiomsl.util.ui.*;
import axiomsl.util.ui.print.*;
import axiomsl.util.*;
import axiomsl.dataview.*;
import axiomsl.util.condition.*;
import axiomsl.lang.NullTerminatedString;
import axiomsl.lang.DataType;
import axiomsl.lang.AxiomDate;
import axiomsl.aggregation.*;
import axiomsl.task.*;

import org.apache.crimson.tree.XmlDocument;
import org.w3c.dom.*;


public abstract class GXML extends TableViewPanel {
    public static void main(String CategoryName, String Taskname, String[] args) {
        try{
            XmlDocument xmlDoc = new XmlDocument();
            Element treedata = ( Element) xmlDoc.createElement("treedata"); //root node
            Element branch = ( Element) xmlDoc.createElement("branch");
            Element ShortDesc = ( Element) xmlDoc.createElement("ShortDesc");
            Element LongDesc = ( Element) xmlDoc.createElement("LongDesc");
            Element metric = ( Element) xmlDoc.createElement("metric");
           
            xmlDoc.appendChild(treedata);
            treedata.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
            treedata.setAttribute("xsi:noNamespaceSchemaLocation","E:\\User\\Work\\Axiom\\AxiomXML\\viewer.xsd");
            treedata.appendChild(branch);
            branch.setAttribute("branch",CategoryName);
            branch.appendChild(ShortDesc);
            branch.appendChild(LongDesc);
            branch.appendChild(metric);
            metric.setAttribute("metriccode","trtr");
            int col;
            int iLogCol = mapPhysicalColumnToLogical(col);
            if (iLogCol >= 0)
            {
            FieldInfo f = getFieldInfoForColumn(col);
            boolean bIsKey = (f != null && f.getAlias().equals(m_RootAlias) && f.m_Field.is_key);
            if (bIsKey)
            {}
            }

            ((XmlDocument)xmlDoc).write( new FileOutputStream(new File("C:\\installaxiom\\axiom_app\\class\\GenXMLTest.xml")));
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
   
}

see for example getFieldInfoForColumn or getColumnCount or mapPhysicalColumnToLogical are part of the DataViewPanel class. it stops here:
public abstract class GXML extends TableViewPanel {

telling me:

GXML.java [34:1] cannot resolve symbol
symbol  : constructor TableViewPanel ()
location: class axiomsl.toolkit.dataviewer.TableViewPanel
public abstract class GXML extends TableViewPanel {
                ^
GXML.java [54:1] non-static method mapPhysicalColumnToLogical(int) cannot be referenced from a static context
            int iLogCol = mapPhysicalColumnToLogical(col);
                          ^
GXML.java [57:1] non-static method getFieldInfoForColumn(int) cannot be referenced from a static context
                FieldInfo f = getFieldInfoForColumn(col);
                              ^
GXML.java [58:1] non-static variable m_RootAlias cannot be referenced from a static context
                boolean bIsKey = (f != null && f.getAlias().equals(m_RootAlias) && f.m_Field.is_key);
                                                                   ^
4 errors
Errors compiling GXML.

obviously the three last erros are caused because of the first one. how can he launch a function if it doesn't even recognize that class they come from. right?

so what about the first error?
1) First of all change

         public abstract class GXML extends TableViewPanel {

into

         public class GXML extends TableViewPanel {

2) You extend a class TableViewPanel, but your class doesn't have a constructor.
    So at least forsee a constructor (with the same parameters as TableViewPanel) that calls the one of TableViewPanel

   example:

       public GXML(String parameter) {
          super(parameter);
       }

    I don't know what parameters TableViewPanel expects. Have a look.

The other errors come from the fact that you call non-static TableViewPanel functions in your static main function.
Your main function is static: that means it can be called without instantiating an object of GXML:

It can be called as:   GXML.main();

No instantiation like this needed:
           GXML myApp = new GXML();
           myApp.main();

Of course, since e.g. getFieldInfoForColumn() is NOT static this doesn't work like that.

Solution move all what you have in your main to a myFunction() function:

public class GXML extends TableViewPanel {
    static void main() {
        GXML myApp = new GXML(...);   // with parameter(s) I don't know
        myApp.myFunction();
    }

    public void myFunction() {
        // Here you can call the non-static functions of TableViewPanel
    }
}
Avatar of miraodb

ASKER

ok first dataviewpanel doesn''t take any parameter. is it wierd ?
here is a part of the code coz it's huge !!!!!

public abstract class TableViewPanel extends SpreadSheetPanel
{
      public static final String UPREF_LOAD_BUFFER_SIZE = "dataviewer.load_buffer_size";

      public static final int DEFAULT_LOAD_BUFFER_SIZE = 100;
      public static final int MAX_LOAD_BUFFER_SIZE = 10000;
      ..............

then i think this is the constructor:
protected TableViewPanel(Object parent)
{
      super(parent);
      m_sUserName = User.getUserName();
      if (parent != null)
      {
            if (parent instanceof DataViewerPlugIn)
            {
                  m_ParentView = (DataViewerPlugIn)parent;
                  _parent = m_ParentView.m_Editor.getFrame();
            }
            else
                  _parent = (AxiomFrame)parent;
      }
      // else creating a no-view instance
}

as u can see only one parameter is Object parent but it's the same for the SpreadSheetPanel and it didn't have to specify any parameter in dataviewpanel.

ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of miraodb

ASKER

hi zzynx,

so for late answer but i was working on this **** trying to make it work.
and i finally managed to make the classes and packages work fine.

i just have a tiny question now and the points are urs ;)

i want to set the value for a node:

something like that:
<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <branch branchtype="AGGR">sCategory
            <shortdescription>avg_bal_aggr</shortdescription>sTask
            <longdescription>Average Balance Aggregation</longdescription>
      </branch>
</treedata>

so here is what i've done:

XmlDocument xmlDoc = new XmlDocument();
            Element treedata = ( Element) xmlDoc.createElement("treedata"); //root node
            Element branch = ( Element) xmlDoc.createElement("branch");
            Element ShortDesc = ( Element) xmlDoc.createElement("ShortDesc");
            Element LongDesc = ( Element) xmlDoc.createElement("LongDesc");
            Element metric = ( Element) xmlDoc.createElement("metric");
           
            xmlDoc.appendChild(treedata);
           
            treedata.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
            treedata.setAttribute("xsi:noNamespaceSchemaLocation","E:\\User\\Work\\Axiom\\AxiomXML\\viewer.xsd");
            treedata.appendChild(branch);
           
            branch.setAttribute("branchtype",CategoryName);
            branch.appendChild(ShortDesc);
            branch.appendChild(LongDesc);
           
            ShortDesc.setNodeValue("string"); // does nothing
            LongDesc.setNodeValue("string"); // does nothing

everything works fine except the two last lines, they don't put the strings as value, my node are empty.
here is the result:

<?xml version="1.0" encoding="UTF-8"?>

<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <branch branchtype="AGGR">
    <ShortDesc />
    <LongDesc />
  </branch>
</treedata>

i don't have any errors !
what can i do.
I think you should write:

ShortDesc.setAttribute("ShortDesc", "my short description");
LongDesc.setAttribute("LongDesc", "my long description");


Avatar of miraodb

ASKER

yes i understand ur point but i want to use the value of the element not the value of the attribute.

i mean:

<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <branch branchtype="AGGR">sCategory
          <shortdescription>avg_bal_aggr</shortdescription>sTask
          <longdescription>Average Balance Aggregation</longdescription>
     </branch>
</treedata>

not this:
<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <branch branchtype="AGGR">sCategory
          <shortdescription desc="avg_bal_aggr" />
          <longdescription desc="Average Balance Aggregation />
</branch>
</treedata>

Try this:

Attr ShortDesc = ( Element) xmlDoc.createAttribute("ShortDesc");
Attr LongDesc = ( Element) xmlDoc.createAttribute("LongDesc");

and then

ShortDesc.setNodeValue("string");
LongDesc.setNodeValue("string");
Look at the table at http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html
and you'll understand why I'm thinking that.
Avatar of miraodb

ASKER

yeah value for element = null ! damn it now i understand. but i really need to get the value though coz i need to fit a DTD that i didn't do and couldn't change neither.

any idea ??
>> ...but i really need to get the value though coz i need to fit a DTD that i didn't do and couldn't change neither.
???
I thought you wanted to SET a value. Now, you're talking about GETting a value???

Sorry, XML is not my thing. I'd like to help, but I don't understand...
Avatar of miraodb

ASKER

ok no worries, i didn't get, i want to set the value of the the <shortdescription> element to a string.
that's it.

anyway the points are urs for what u've done before.
OK. Thanks for accepting
Success.