In Java Swing if you want to add a listener to a component, it would look something like this...
JButton j = new JButton();
int counter = 0;
j.addAncestorListener(new AncestorListener() {
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorAdded(AncestorEvent event) {
counter++;
}
@Override
public void ancestorRemoved(AncestorEvent event) {
}
});
If I were able to create a new Java keyword and just say this....
JButton j = new JButton();
int counter = 0;
swinglistener (j, AncestorListener) {
ancestorAdded {
counter++;
}
}
.... to achieve the same effect. Would this code be more readable? Would it be better? What other aspects of "good" software design would this change achieve?