From: Davis, K. A <kim...@in...> - 2003-09-10 17:18:32
|
Sure, I will try to give you some other details, but I am not sure what info I can provide that would be of assistance in understanding this problem. I am using Jython-2.1 and my development environment is ActiveState Komodo 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 am using a split panel to separate it from the other parts of the window. 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, this is sloppy and a bit embarrassing. 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. Thanks in advance for any insight you may have. KD -----Original Message----- From: Jeff Emanuel [mailto:JEm...@lg...]=20 Sent: Wednesday, September 10, 2003 8:39 AM To: Davis, Kimberly A Subject: RE: [Jython-users] Understanding the Limitations of Abstract Classes =20 I don't see anything wrong with you've done. Perhaps you can explain more about when and how the error occurs. -----Original Message----- From: Davis, Kimberly A [mailto:kim...@in...] Sent: Monday, August 18, 2003 3:57 PM To: jyt...@li... Subject: [Jython-users] Understanding the Limitations of Abstract Classes 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):=20 public int getRowCount(); public int getColumnCount(); public Object getValueAt(int row, int column); =20 Here is the jython class: =20 class cMyTableData(swing.table.AbstractTableModel): #---------------------------------------------------------- # __init__ Constructor # Initializes all member data. # #----------------------------------------------------------=20 def __init__(self): self.path =3D cColumnData(COLUMN_1, 50, swing.JLabel.LEFT) self.lineno =3D cColumnData(COLUMN_2, 50, swing.JLabel.LEFT) self.columns =3D [ self.path,self.lineno] self.vector =3D java.util.Vector() self.vector.removeAllElements() =20 def getColumnCount(self): # code particular to my situation =20 def getRowCount(self): # code particular to my situation =20 def getValueAt(self, nRow, nCol): # code particular to my situation =20 #An additional function I've added... def sortMyData(self, thing): =20 # blah, blah, blah... =20 When I add sortData, to this class, I get an error: AttributeError: sortMyData =20 Why does this particular class restrict me? Does anyone know? I have tried the same thing with AbstractList with success. =20 Thanks in advance for any information, KD =20 |