From: Oti <oh...@ya...> - 2003-09-17 20:32:47
|
Hello Kimberly, Just FYI: I even tried to 'non-implement' AbstractTableModel like this: from javax.swing.table import AbstractTableModel class cMyTableData(AbstractTableModel): def __init__(self): pass def sortMyData(self, thing): print thing if __name__ == "__main__": td = cMyTableData() td.sortMyData( "thingee" ) and the interpreter did not complain as long as I did not call a method of AbstractTableModel. Best wishes, Oti. --- "Davis, Kimberly A" <kim...@in...> wrote: > 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:be...@be...] > Sent: Wednesday, September 10, 2003 3:00 PM > To: Davis, Kimberly A > Cc: jyt...@li... > 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 > <https://mail.intermedium.com/src/download.php?absolute_dl=true&passed_i > d=94&passed_ent_id=0&mailbox=Sent&showHeaders=1> > > > > Forrige | Neste > <https://mail.intermedium.com/src/read_body.php?passed_id=93&mailbox=Sen > t&sort=0&startMessage=1&show_more=0> | Delete & Prev | Delete & > Next > <https://mail.intermedium.com/src/read_body.php?passed_id=93&mailbox=Sen > t&sort=0&startMessage=1&show_more=0&delete_id=94> > Move to: INBOX Drafts Sent Trash Differ General_done > General_todo Jobb HiA Mailinglists/Apache > Mailinglists/Cryptogram > Mailinglists/Developer Works Mailinglists/Dr. Dobbs > Mailinglists/ikt_hia03 Mailinglists/Jython Mailinglists/nltk > Mailinglists/Python Url Mailinglists/Python Web Mailinglists/PyX > Mailinglists/test Mailinglists/TuT Mailinglists/Windows Developer > Mailinglists/xindice_dev Mailinglists/xindice_users Of interest > Personal Read Resources/Done Resources/GenTodo Resources/PriA > Resources/PriB Review Service/backend Service/basehopp > Service/fehode Service/miscellanious Service/prekestol > Service/QA > Service/vertshus Service/vevstol System_errors Wiki > > > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |