I have designed this method to display a window with a slider which value I need to return. Can you please tell me how I can retrieve the JSlider value a currently I am getting the error: "local variables referenced from an inner class must be final or effectively final"?
private static int displayFontPanel(JFrame w){
    JFrame window = new JFrame("Font Settings");
    window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    int fontSize = 14;
    window.setSize(400, 200);
    window.setLocationRelativeTo(w);
    JSlider fntSize = new JSlider(8,40,20);
    fntSize.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            fontSize = ((JSlider)evt.getSource()).getValue();
        }
    });
    fntSize.setLabelTable( fntSize.createStandardLabels(8) );
    fntSize.setPaintLabels(true);
    panel.add(fntSize, BorderLayout.CENTER);
    window.setContentPane(panel);
    window.setVisible(true);
    return fontSize;
} 
 
     
     
     
     
    