Skip to main content

Java Delegate Syntax/type-safe function pointers

No replies
pcwheels
Offline
Joined: 2003-06-11
Points: 0

Hi,

I was just wondering if there are any plans to introduce some kind of type-safe function pointers to the Java language.

The problem I would like to solve is having to write:

myButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.toFront();
}
});

I was thinking of something like:

myButton.addActionListener(frame#toFront());

Using the # could return an instance of java.lang.reflect.Method.