First of all, I have to admit that I do not search my problem on the web because I don't know which keywords match with my issue. I have just a couple hour experience with java and I have came across with the following syntax:
public class Simulation extends JFrame {
// some fields...
public Simulation() {
ActionListener listener1 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
InputStream pauseStream;
try {
pauseStream = new FileInputStream("/pause.wav");
PM = new AudioStream(pauseStream);
} catch (Exception e) {
e.printStackTrace();
}
setPause(!isPause());
if(isPause()) {
button1.setText("Play");
MGP.stop(BGM);
MGP.start(PM);
} else {
button1.setText("Pause");
MGP.start(PM);
MGP.start(BGM);
}
}
};
}
// other methods
}
Unfortunately, I did not understand meaning of the following line (I mean whether its function, class or something like that) ActionListener listener1=new ActionListener() {
because, as I remember there is no correspondence in C or C++ .
If I'm not wrong, by ActionListener listener1=new ActionListener() should create an ActionListener instance but what is the code in following curly brackets ?