I want to write program in which you can chance scene (JPanel
) thanks to JComboBox
.
I used ActionListener
, but it doesn't work.
At the beginning of constructor I defined panel as final, but it didn't help.
scene.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String choice = String.valueOf(scene.getSelectedItem());
if(choice=="Sceneria"||choice=="Scene"){
slider.setEnabled(false);
panel = new JPanel();// problem here
}
}
});
Error
The final local variable panel cannot be assigned, since it is defined in an enclosing type