Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37844

How do you listen to GUI?

From Eric Douglas <e.d.programmer@gmail.com> (Eric Douglas)
Newsgroups comp.lang.java.programmer
Subject How do you listen to GUI?
Date 2017-12-12 13:57 +1200
Organization fsxNet Usenet Gateway | bbs.geek.nz/#fsxNet
Message-ID <3937588803@f38.n261.z1.binkp.net> (permalink)

Show all headers | View raw


Many GUI objects have to listen to themselves, such as the JTree listener that
expands or collapses nodes.  I've seen this done in many classes in different
ways.  Is there really a best practice, has the best practice simply changed
over time, or is there a reason for doing it each way?

Many test classes you'll find on the internet simply have the class implement
the listener class and add itself as the listener.  I did some of this and at
some point thought it seemed odd for a class to implement a listener interface
if it'll only ever listen to itself and wrote some listeners as anonymous
classes.  I have a few listener methods that looked too complex so I made them
inner classes.  Now I've noticed at least in some places like JTree, Oracle
uses an inner class which extends a class called AccessibleJComponent, and I
don't understand why.

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

How do you listen to GUI? Eric Douglas <e.d.programmer@gmail.com> (Eric Douglas) - 2017-12-12 13:57 +1200

csiph-web