Some code I'm maintaining uses unfamiliar syntax. I haven't been able to find examples of this syntax in the Java docs.
public static void main(String[] args){
...
javax.swing.SwingUtilities.invokeLater(new MyClass.1());
...
}
and
public MyClass(a,m){
...
javax.swing.myJButton.addActionListener(new MyClass.5(this));
...
}
Q1. What do '.1' and '.5' mean and do?
Q2. What does '(this)' do? Is it shorthand for (this.param1, this.param2,...)?
Q3. Is this syntax especially for anonymous object instantiation, javax.swing components, Runnables, multithreading, etc., or is it general use?
Q4. Another version of this code uses more familiar syntax. Are these statements syntactically equivalent to the ones above (notwithstanding the different constructor call and event behavior)?
javax.swing.SwingUtilities.invokeLater(
new Runnable(){
public void run(){
new MyClass(a,m);
}
}
);
and
javax.swing.myJButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
myJTextField.grabFocus();
}
}
);