I couldn't save the new things when i tried to pass in new value inside inner class.
The error message is local variable item is accessed from within inner class; needs to declared final. Guide me please. thanks in advance
public class Broadcast{
protected String title;
public Broadcast(String title){
this.title=title;}
public void setTitle (String title){
this.title= title;
}
public String getTitle (){
return title;
}
}
public class test{
static Broadcast item[] = new Broadcast();
JFrame ammendFilmFrame= new JFrame();
private JButton = ammendTitleButton;
public static void main(String [] args){
ammendFilmFrame.setTitle("Ammend Film menu");
ammendFilmFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ammendFilmFrame.setSize(240,500);
ammendFilmFrame.setLocationRelativeTo(null);
ammendFilmFrame.setVisible(true);
JPanel ammendFilmPanel= new JPanel(new FlowLayout());
ammendFilmBox[0].add( Box.createRigidArea( new Dimension(12,8)));
ammendFilmBox[0].add(ammendTitleButton = new JButton("Title"));
ammendTitleButton.setMaximumSize(new Dimension(240,40));
ammendFilmFrame.add( ammendFilmBox[0], BorderLayout.WEST );
ammendTitleButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
do{
newAmmendTitle = JOptionPane.showInputDialog(null, "Enter new Title For Ammend Process: ", "Ammend Title", JOptionPane.PLAIN_MESSAGE);
if((newAmmendTitle == null) || newAmmendTitle.matches("^\\s*$")){
JOptionPane.showMessageDialog(null, "ERROR ! \nProcess Interupted. \nPlease Do Not Interupt Program by Clicking Exit Button or Cancel Button.","Error Message", JOptionPane.WARNING_MESSAGE);
}
if(newAmmendTitle.length()<=0){
JOptionPane.showMessageDialog(null, String.format("Please enter valid data to proceed." +
"\nError: Do not leave BLANK at Title field." +
"\nPlease Retype the Title Field"), "Ortsa Sdn. Bhd.",JOptionPane.ERROR_MESSAGE);
}
}while(newAmmendTitle==null || newAmmendTitle.matches("^\\s*$")|| newAmmendTitle.length()<0);
item[i].setTitle(newAmmendTitle);
}
});
}