Yes, Bent, you are correct in your assessment below. I can only give you the information that I have given Jeff Emmanuel, another participant in the Jython users group. To summarize quickly:

 

I do remember jython did not complain about the setting of the model. It complained about the class definition itself. When I invoked the interpreter, I got a message (I am paraphrasing obviously) that was something like: Error- AbstractTableModel is an abstract class. Cannot add sortMyData method to an abstract class. I am using Jython 2.1 with the Komode IDE 2.0 professional.

 

I supply the class described in my first posting as a model to a simple swing JTable. I set the model this way: self.tblSearchOutput.setModel(self.searchTableModel)

 

The JTable is on a JFrame with several other GUI components.

 

I was able to get around the problem I described by creating another class, which has the extra sorting methods that I need, and allowing my model class to inherit from both these classes:

 

class cMyTableData(swing.table.AbstractTableModel, cSearchTableSorter):

 

Admittedly, sloppy. However, as is often the case, the show must go on, and I could not seem to reason through this problem. No matter what I did, Jython complained about my adding the sortMyData method to a class inheriting from the AbstractTableModel, and I had to do something to fix the problem.

 

There has been some lag time between when I had posted this problem to the jython user group and when I received any interest in the form of responses. I can't reproduce the error exactly because my code base has moved on substantially. I wish I had had the foresight to freeze and label that particular point in the project in case somebody responded.

 

It’s just weird to me that I haven’t had this problem with other abstract classes.

 

KD

 

-----Original Message-----
From: Bent Andre Solheim [mailto:bent@bent-andre.com]
Sent: Wednesday, September 10, 2003 3:00 PM
To: Davis, Kimberly A
Cc: jython-users@lists.sourceforge.net
Subject: RE: [Jython-users] Understanding the Limitations of Abstract Classes

 

Hi Kimberly,
 
I'm not sure if I have understood your problem, so please correct me if I
am wrong;
You are subclassing a Java class i Jython and wish to use this class
together with some other javax.swing class? It looks to me as if you are
working with your object through a limited interface, for instance through
javax.swing.table.TableModel which AbstractTableModel implements, or
through the public interface of AbstractTableModel itself. Which interface
you are working with depends on how you created your object (or got a hold
of it). I am unable to help you more without seeing more code...
Hope this helps
 
regards
Bent
 
 
 
 
> Perhaps this problem has been covered already, but I haven't been able
> to find the answer in documentation or user groups. I am using an
> abstract class called AbstractTableModel. To create a concrete
> TableModel as a sublcass of AbstractTableModel you need only provide
> implementations for the following three methods (which I've done):
>  public int getRowCount();
>  public int getColumnCount();
>  public Object getValueAt(int row, int column);
>
> Here is the jython class:
>
> class cMyTableData(swing.table.AbstractTableModel):
>    #----------------------------------------------------------
>    # __init__ Constructor
>    # Initializes all member data.
>    #
>    #----------------------------------------------------------
>    def __init__(self):
>        self.path = cColumnData(COLUMN_1, 50, swing.JLabel.LEFT)
>        self.lineno = cColumnData(COLUMN_2, 50, swing.JLabel.LEFT)
>        self.columns = [ self.path,self.lineno]
>        self.vector = java.util.Vector()
>        self.vector.removeAllElements()
>
>    def getColumnCount(self):
>           # code particular to my situation
>
>    def getRowCount(self):
>        # code particular to my situation
>
>    def getValueAt(self, nRow, nCol):
>       # code particular to my situation
>
>    #An additional function I've added...
>    def sortMyData(self, thing):
>        # blah, blah, blah...
>
> When I add sortData, to this class, I get an error: AttributeError:
> sortMyData
>
> Why does this particular class restrict me? Does anyone know? I have
> tried the same thing with AbstractList with success.
>
> Thanks in advance for any information,
> KD
>
 
 
 

Last ned dette som en fil

 

 

 

Forrige | Neste |  Delete & Prev | Delete & Next

Move to: