From: BillWorker 2. <bil...@in...> - 2002-03-11 05:00:45
|
From: Ype Kingma <yk...@xs...> Subject: Re: [Jython-users] Swing examples > Ahish, > > >This is more of what I learnt while working with Jython and Swings! > > > >First, if you want to use Swings and its MVC architecture, you have to > >remember Swing is designed to work it Java objects. For example, when > >working with JList, I wanted to implement my own ListModel so I extended the > >AbstractListModel and went about writing my implementations of > >getElementAt() and getSize(). It took me one whole day of fooling around to > >realize that the object returned by getElementAt() should be an instance > >java.lang.Object. > > I suppose the compiler did not allow you to override the return value > of getElementAt() to a java basic type like int or char? > In case you override in jython code, jython will try and convert the returned > python object to an appropriate java object, which works surprisingly > well. What do you mean by override jython code? Sure, an easy way to convert python object to java object is to inherit from java.lang.Object. or other similar class. This is what I wanted to mention. Since, I started out with Java and when we don't mention explicitly the base class it is automatically made java.lang.Object. This is one thing we forget while working in Jython, so I just wanted to have this thing mentioned in FAQ. It took me a day to realise that Python objects do not inherit from java.lang.Object unless explicitly mentioned. This would be a nice reminder to any Java programmers! Of course, the other option is to make sure the whatever we return from getElementAt() is wrapped by a Java object. > >If you remember this and have the looks at the bean section of the docs, > >then any Swing books is good. > > > >Somehow, you just don't remember that. The examples all use strings and that > >is automatically handled. > > > >Guess someone should add that section to the FAQ! > > I'm afraid I don't understand your problem well enough. > > >Oh, about the shameless plug for Jython Essentials, guess I will wait till > >it becomes available in my part of the world (Kathmandu, Nepal). If it ever > >comes :-( Since, I don't have International credit cards I can't do online > >shopping and I don't think I would really like to go through all the hassel > >at banks, getting permissions for making dollar payments .... In short, > >visits to multiple organisations! > > You only need the Swing API docs, the Swing examples from Sun, > and a few jython examples on using Swing to get going. All of > this is downloadable, no paper needed. Yup, I don't think I would by a Jython book to learn Swings. That I have all the docs I need. I would by Jython book to see how Python works with Java! Or rather how to write more Pythonlike (Pythonic??) code! > Have fun, That's exactly what I am doing! > Ype > > P.S. You replied in private, which is ok to me, but it might not > have been your intention. (My mail program does not by default > reply to the list, but to the original sender, so I always have > to cut and past the list address to return to the list.) > I just realised neither does mine! |