Prev: NetBeans and Web Service issue
Next: Newbie Q. Accessing a variable in one method from another.
From: Daniel Pitts on 22 Jun 2010 14:30 On 6/22/2010 6:40 AM, Hole wrote: > Hi There, > > I was looking for a solution to bind Swing widgets and beans (or list > of beans). > Surprisingly, I've found some projects on dev.java.net that are > completely overlapped and it's not clear which project is active or > not (as for JSRs). > > In Java 6 SE, there's no bean binding implementation. > > So, is anyone aware of a standard, stabilized and wide-used by java > community for bindings? > > In particular, I was looking for some patterns/libraries that allows > to bind directly a JTable and a list of beans. And, for instance, > retrieve the bean which corresponds to a selected row in a JTable and > binding properties of this selected bean to text properties of some > JLabels (imagine a panel with detailed info about the selected > object). > > BTW, I'm really disappointed about this mess around... > > Thanks in advance, > -- > -d The trouble with this is that the JTable Model is event driven, where user-beans need a lot of work to add event notification for property modification. I've tried to write such a library several times, and always run into the same issues. Also, custom renders and editors for bean properties aren't easy to handle in certain cases. Also note, that while it is certainly a common use-case to have a table which is bindable to a list of beans, the JTable is much more flexible (think spread-sheet, or special "command" rows, etc...), and can have different "sections" of the same table be treated differently. It *is* possible to create an object which implements both java.util.List and javax.swing.ListModel, the trouble comes from mutable objects. IF the object mutates, technically an event needs to be fired. In order to handled that, the beans have to register listeners. A lot of boiler-plate code. Yarg. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
From: Tom Anderson on 22 Jun 2010 14:59 On Tue, 22 Jun 2010, Daniel Pitts wrote: > The trouble with this is that the JTable Model is event driven, where > user-beans need a lot of work to add event notification for property > modification. I've tried to write such a library several times, and > always run into the same issues. Also, custom renders and editors for > bean properties aren't easy to handle in certain cases. > > It *is* possible to create an object which implements both > java.util.List and javax.swing.ListModel, the trouble comes from mutable > objects. IF the object mutates, technically an event needs to be fired. > In order to handled that, the beans have to register listeners. A lot > of boiler-plate code. Yarg. Or else, the binding framework could play at being JPA and take care of dirty tracking. It could play that dead straight and bind to JPA-annotated beans, and use existing code weaving techniques to detect changes, or it could maintain a copy of the state, and diff it with the current state to generate events on demand. It would be memory- and CPU-heavy, but hey, next to Swing, who's going to notice? tom -- We don't contact anybody or seek anybody's permission for what we do. Even if it's impersonating postal employees. -- Birdstuff
From: John B. Matthews on 22 Jun 2010 15:28 In article <alpine.DEB.1.10.1006221957500.16997(a)urchin.earth.li>, Tom Anderson <twic(a)urchin.earth.li> wrote: > On Tue, 22 Jun 2010, Daniel Pitts wrote: > > > The trouble with this is that the JTable Model is event driven, > > where user-beans need a lot of work to add event notification for > > property modification. I've tried to write such a library several > > times, and always run into the same issues. Also, custom renders > > and editors for bean properties aren't easy to handle in certain > > cases. > > > > It *is* possible to create an object which implements both > > java.util.List and javax.swing.ListModel, the trouble comes from > > mutable objects. IF the object mutates, technically an event needs > > to be fired. In order to handled that, the beans have to register > > listeners. A lot of boiler-plate code. Yarg. > > Or else, the binding framework could play at being JPA and take care > of dirty tracking. It could play that dead straight and bind to > JPA-annotated beans, and use existing code weaving techniques to > detect changes, or it could maintain a copy of the state, and diff it > with the current state to generate events on demand. It would be > memory- and CPU-heavy, but hey, next to Swing, who's going to notice? I see NetBeans has a help topic entitled "Binding Data to a Swing Component". It permits binding to either JTable and JList. -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
From: Daniel Pitts on 22 Jun 2010 18:30 On 6/22/2010 11:59 AM, Tom Anderson wrote: > On Tue, 22 Jun 2010, Daniel Pitts wrote: > >> The trouble with this is that the JTable Model is event driven, where >> user-beans need a lot of work to add event notification for property >> modification. I've tried to write such a library several times, and >> always run into the same issues. Also, custom renders and editors for >> bean properties aren't easy to handle in certain cases. >> >> It *is* possible to create an object which implements both >> java.util.List and javax.swing.ListModel, the trouble comes from >> mutable objects. IF the object mutates, technically an event needs to >> be fired. In order to handled that, the beans have to register >> listeners. A lot of boiler-plate code. Yarg. > > Or else, the binding framework could play at being JPA and take care of > dirty tracking. It could play that dead straight and bind to > JPA-annotated beans, and use existing code weaving techniques to detect > changes, or it could maintain a copy of the state, and diff it with the > current state to generate events on demand. It would be memory- and > CPU-heavy, but hey, next to Swing, who's going to notice? I would notice. Swing is actually fairly light weight with resources, since is *is* event driven and not poll driven. Code weaving could actually handle this (and field-write could be wrapped with advice to fire an event, making assumptions about "simple" getter/setter code. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
From: Hole on 23 Jun 2010 03:44 On Jun 22, 4:10 pm, markspace <nos...(a)nowhere.com> wrote: > Hole wrote: > > I was looking for a solution to bind Swing widgets and beans (or list > > of beans). > > Surprisingly, I've found some projects on dev.java.net that are > > completely overlapped and it's not clear which project is active or > > not (as for JSRs). > > Can you share what you found, overlapped or otherwise? I'd be > interested in seeing what has been worked on so far. It might also help > us understand what sort of binding you are looking for. I think most of > us have a general idea but something a little more specific might be > helpful. Hi, thanks for you reply. I'll come back to you with a post presenting various existing alternatives on beans binding (some of them are dismissed). I'll try to explain better (perhaps with some code) my needs...I think that beans binding is a common need in desktop development
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: NetBeans and Web Service issue Next: Newbie Q. Accessing a variable in one method from another. |