The function pointer, a powerful concept in the C and C++ programming
languages, has no direct equivalent in Java. No syntax exists to pass the
address of a method to a JButton, for instance, that links it with pressing
the button. Instead, Java promotes the use of anonymous inner classes, like
this one:
okButton.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { startProcessing(); } });
Back in October 1996, in an attempt to eliminate the need for this bloated
syntax, Microsoft introduced an object-oriented method pointer into J++
called a "delegate." Sun Microsystems, citing the delegate as language
pollution, sued Microsoft a year later for violating its Java license
agreement. The lawsuit successfully maintained the purity of Java,... (more)
Even for many seasoned developers, Swing code can be notoriously difficult to
organize. Where is the right place to put parsing and validation logic? How
do you prevent those threading issues that cause lockups or repainting
glitches? Is it possible to unit test GUI logic? Can the code somehow be
shared with other user-interfaces, like a web front-end? If these questions
sound familiar, ... (more)
If you have a bounty of creative energy and way too much time on your hands,
why not explore the new Java 1.4 APIs by creating a video game. That's
exactly what I did when I produced a parody of Street Fighter II called Meat
Fighter (see Figure 1).
"Meat Fighter" is a side-scrolling one-to-one fighting game featuring
anthropomorphic hot dogs and sausages. You can choose from six possible ... (more)
The function pointer, a powerful concept in the C and C++ programming
languages, has no direct equivalent in Java. No syntax exists to pass the
address of a method to a JButton, for instance, that links it with pressing
the button. Instead, Java promotes the use of anonymous inner classes, like
this one:
okButton.addActionListener(new ActionListener() {
public void actionPerformed(Action... (more)