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
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
That's exactly what I meant with my comment in the original (already closed) Q.
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.replaceNewLines WithHtml(t itle) : "";
sBuffer += "</div></td> ";
}
sBuffer += "</tr>\n";
return sBuffer;
}
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.replaceNewLines
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?
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.
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);
}
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)
>> 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?
Why don't you just call getColumnCount() on that jTable object?
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.jav a
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?
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.jav
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?
What do you import in your code so it "knows" TableViewPanel?
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
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
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.Ta bleViewPan el
public abstract class GXML extends TableViewPanel {
what's wonrg?
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.Ta
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)
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?
;)
;)
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.NullTerminate dString;
import axiomsl.lang.DataType;
import axiomsl.lang.AxiomDate;
import axiomsl.aggregation.*;
import axiomsl.task.*;
import org.apache.crimson.tree.Xm lDocument;
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("tree data"); //root node
Element branch = ( Element) xmlDoc.createElement("bran ch");
Element ShortDesc = ( Element) xmlDoc.createElement("Shor tDesc");
Element LongDesc = ( Element) xmlDoc.createElement("Long Desc");
Element metric = ( Element) xmlDoc.createElement("metr ic");
xmlDoc.appendChild(treedat a);
treedata.setAttribute("xml ns:xsi","http://www.w3.org/2001/XMLSchema-instance" );
treedata.setAttribute("xsi :noNamespa ceSchemaLo cation","E :\\User\\W ork\\Axiom \\AxiomXML \\viewer.x sd");
treedata.appendChild(branc h);
branch.setAttribute("branc h",Categor yName);
branch.appendChild(ShortDe sc);
branch.appendChild(LongDes c);
branch.appendChild(metric) ;
metric.setAttribute("metri ccode","tr tr");
int col;
int iLogCol = mapPhysicalColumnToLogical (col);
if (iLogCol >= 0)
{
FieldInfo f = getFieldInfoForColumn(col) ;
boolean bIsKey = (f != null && f.getAlias().equals(m_Root Alias) && f.m_Field.is_key);
if (bIsKey)
{}
}
((XmlDocument)xmlDoc).writ e( new FileOutputStream(new File("C:\\installaxiom\\ax iom_app\\c lass\\GenX MLTest.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 .TableView Panel
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_Root Alias) && 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?
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.NullTerminate
import axiomsl.lang.DataType;
import axiomsl.lang.AxiomDate;
import axiomsl.aggregation.*;
import axiomsl.task.*;
import org.apache.crimson.tree.Xm
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("tree
Element branch = ( Element) xmlDoc.createElement("bran
Element ShortDesc = ( Element) xmlDoc.createElement("Shor
Element LongDesc = ( Element) xmlDoc.createElement("Long
Element metric = ( Element) xmlDoc.createElement("metr
xmlDoc.appendChild(treedat
treedata.setAttribute("xml
treedata.setAttribute("xsi
treedata.appendChild(branc
branch.setAttribute("branc
branch.appendChild(ShortDe
branch.appendChild(LongDes
branch.appendChild(metric)
metric.setAttribute("metri
int col;
int iLogCol = mapPhysicalColumnToLogical
if (iLogCol >= 0)
{
FieldInfo f = getFieldInfoForColumn(col)
boolean bIsKey = (f != null && f.getAlias().equals(m_Root
if (bIsKey)
{}
}
((XmlDocument)xmlDoc).writ
}
catch (Exception e) {
e.printStackTrace();
}
}
}
see for example getFieldInfoForColumn or getColumnCount or mapPhysicalColumnToLogical
public abstract class GXML extends TableViewPanel {
telling me:
GXML.java [34:1] cannot resolve symbol
symbol : constructor TableViewPanel ()
location: class axiomsl.toolkit.dataviewer
public abstract class GXML extends TableViewPanel {
^
GXML.java [54:1] non-static method mapPhysicalColumnToLogical
int iLogCol = mapPhysicalColumnToLogical
^
GXML.java [57:1] non-static method getFieldInfoForColumn(int)
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_Root
^
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
}
}
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
}
}
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_si ze";
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.getF rame();
}
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.
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_si
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.getF
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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">sCategor y
<shortdescription>avg_bal_ aggr</shor tdescripti on>sTask
<longdescription>Average Balance Aggregation</longdescripti on>
</branch>
</treedata>
so here is what i've done:
XmlDocument xmlDoc = new XmlDocument();
Element treedata = ( Element) xmlDoc.createElement("tree data"); //root node
Element branch = ( Element) xmlDoc.createElement("bran ch");
Element ShortDesc = ( Element) xmlDoc.createElement("Shor tDesc");
Element LongDesc = ( Element) xmlDoc.createElement("Long Desc");
Element metric = ( Element) xmlDoc.createElement("metr ic");
xmlDoc.appendChild(treedat a);
treedata.setAttribute("xml ns:xsi","http://www.w3.org/2001/XMLSchema-instance" );
treedata.setAttribute("xsi :noNamespa ceSchemaLo cation","E :\\User\\W ork\\Axiom \\AxiomXML \\viewer.x sd");
treedata.appendChild(branc h);
branch.setAttribute("branc htype",Cat egoryName) ;
branch.appendChild(ShortDe sc);
branch.appendChild(LongDes c);
ShortDesc.setNodeValue("st ring"); // does nothing
LongDesc.setNodeValue("str ing"); // 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.
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">sCategor
<shortdescription>avg_bal_
<longdescription>Average Balance Aggregation</longdescripti
</branch>
</treedata>
so here is what i've done:
XmlDocument xmlDoc = new XmlDocument();
Element treedata = ( Element) xmlDoc.createElement("tree
Element branch = ( Element) xmlDoc.createElement("bran
Element ShortDesc = ( Element) xmlDoc.createElement("Shor
Element LongDesc = ( Element) xmlDoc.createElement("Long
Element metric = ( Element) xmlDoc.createElement("metr
xmlDoc.appendChild(treedat
treedata.setAttribute("xml
treedata.setAttribute("xsi
treedata.appendChild(branc
branch.setAttribute("branc
branch.appendChild(ShortDe
branch.appendChild(LongDes
ShortDesc.setNodeValue("st
LongDesc.setNodeValue("str
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("Sh ortDesc", "my short description");
LongDesc.setAttribute("Lon gDesc", "my long description");
ShortDesc.setAttribute("Sh
LongDesc.setAttribute("Lon
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">sCategor y
<shortdescription>avg_bal_ aggr</shor tdescripti on>sTask
<longdescription>Average Balance Aggregation</longdescripti on>
</branch>
</treedata>
not this:
<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<branch branchtype="AGGR">sCategor y
<shortdescription desc="avg_bal_aggr" />
<longdescription desc="Average Balance Aggregation />
</branch>
</treedata>
i mean:
<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<branch branchtype="AGGR">sCategor
<shortdescription>avg_bal_
<longdescription>Average Balance Aggregation</longdescripti
</branch>
</treedata>
not this:
<treedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<branch branchtype="AGGR">sCategor
<shortdescription desc="avg_bal_aggr" />
<longdescription desc="Average Balance Aggregation />
</branch>
</treedata>
Try this:
Attr ShortDesc = ( Element) xmlDoc.createAttribute("Sh ortDesc");
Attr LongDesc = ( Element) xmlDoc.createAttribute("Lo ngDesc");
and then
ShortDesc.setNodeValue("st ring");
LongDesc.setNodeValue("str ing");
Attr ShortDesc = ( Element) xmlDoc.createAttribute("Sh
Attr LongDesc = ( Element) xmlDoc.createAttribute("Lo
and then
ShortDesc.setNodeValue("st
LongDesc.setNodeValue("str
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.
and you'll understand why I'm thinking that.
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 ??
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...
???
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...
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.
that's it.
anyway the points are urs for what u've done before.
OK. Thanks for accepting
Success.
Success.
int nCols = getColumnCount();
---
int nCols = theTable.getColumnCount();