"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Can anyone tell me why Swing (or AWT...or Java, for that matter) doesn't have an EventProducer interface?
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:The only thing I can think of, as to the proliferation of types, is that it allows compile-time checking and, maybe (if you believe in such things) a degree of self-documentation.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:Whaddayathink?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Another possibility of course is that it was all done before enums were part of the Java multiverse
"Il y a peu de choses qui me soient impossibles..."
Winston Gutkowski wrote:
Stevens Miller wrote:Whaddayathink?
Ooof. A bit much for an evening after sevurial beers; but you get a cow for effort, and I'll look it over as soon as I can.
"Il y a peu de choses qui me soient impossibles..."
Agree with Stevens. Swing came out in Java1.2 about 1997 and like many of the earlier versions it suffered (maybe: naughty suggestion follows) from being rushed out before enums generics etc were completed. In those days the easiest way to define such options was with constant ints. If you look at some classes e.g. BigDecimal you find some methods have been overloaded to take more modern programming with RoundingMode which uses enums. If you look in the Swing Package, you find there are a few enums. Obviously they never updated the methods to take such enums, maybe because people had already got used to using ints.Winston Gutkowski wrote:. . . Another possibility of course is that it was all done before enums were part of the Java multiverse . . .
Stevens Miller wrote:Whaddayathink?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie wrote:On the other had, Swing is probably on its way out, to be replaced by JavaFX; if we look in a JavaFX package you find it has two enums in.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Karthik Shiraly wrote:JavaFX 8 tutorials are good to start off.
Edit: Just noticed some of your links are to JavaFX 2. Since JavaFX API is still evolving, it's better to use JavaFX 8 javadocs
As for this discussion, I'm coming in a bit late, but if I understood right, the question is regarding the explosion of Event subtypes and event handler methods subtypes in Swing.
If that's so, I'm afraid JavaFX programming model does not improve much upon it. It too has a fairly deep Event hierarchy and adding handlers involves calling one of the many Node.set<event>Handlers.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are three kinds of actuaries: those who can count, and those who can't.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:EventHandler appears to be a functional interface. So you can use it in a λ.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Piet Souris wrote:I do not quite understand what the problem is. Indeed, depending on the component, you might need to choose what specific xxxListener to add.
There are umpteen other Listeners as well, but my experience is that the components for which you need to add some specialist Listeners are already so complex, that the Listener is only a tiny portion of the problem.
As Karthik says, in JavaFX you can indeed use 'addEventHandler' in the way you described a long time ago in your opening post, but you still need to know what kind of Event you need to have, and add code that can handle the Event you're interested in.
All I can advise is: if you really want to get into all sorts of GUI, whether FX or Swing or whatever, just start and practise.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Don't get me started about those stupid light bulbs. |