With slight modifications, it worked for me (Jython 2.1,Win2k, JDK1.4).
Here's my version:
from javax.swing import *
class MyCellRenderer(JLabel, ListCellRenderer):
self.myIcon = ImageIcon("someicon.gif")
def getListCellRendererComponent(self ,list, value, isIndex, selected,
s = `value`
# This works better, it doesn't put quotes in s
# s = java.lang.String.valueOf(value)
# Gratuitous converson to jython bean-property syntax:
self.text = s
self.icon = self.myIcon
self.opaque = 1
myList = JList(["this","is","a","test"])
f = JFrame()
David Robertson wrote:
> Does anyone have any tips on how I can get the following to work.
> from javax.swing import *
> class MyCellRenderer(JLabel, ListCellRenderer):
> def OnInit(self):
> self.myIcon = ImageIcon("someicon.bmp")
> def getListCellRendererComponent(self ,list, value, isIndex, selected,
> s = value.toString()
> return self
> myList = JList(["this","is","a","test"])
> The constructor for MyCellRenderer is called, but
> getListCellRendererComponent is never called. I have tried many different
> combos, and read all jython docs I could find.
> I am in the process of writing a FTP browser plugin for Jext because the one
> offered on thier site does not work, I have everything coded except the
> above (which is just a very brief version). I was trying to write it in
> Jython first as a test bed.
> Thanks, Dave
> This sf.net email is sponsored by: OSDN - Tired of that same old
> cell phone? Get a new here for FREE!
> Jython-users mailing list