title: Getting a variable value from a java action listener?
body: <p>Sorry for the newbish question, I'm trying to create a GUI for a simple application using JAVA and Swing but I'm stuck trying to get a variable value generated within an action listener from the outside.</p>
  
  <pre><code>public geRes() 
  {
      setTitle("geRes");
      setBounds(100, 100, 272, 308);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
  
  
  
      JButton btnNewButton = new JButton("igen");
      btnNewButton.addMouseListener(new MouseAdapter() 
      {
  
          @Override
          public void mouseClicked(MouseEvent e) 
          {
                JFileChooser fc = new JFileChooser();
                fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                fc.showOpenDialog(fc.getParent());
                fc.getName();
          }
      });             
      btnNewButton.setToolTipText("Selec");
      getContentPane().add(btnNewButton);
  
      JButton btnCivos = new JButton("smbinar");
      btnCivos.addMouseListener(new MouseAdapter() 
      {
          @Override
          public void mouseClicked(MouseEvent e) 
          {
                  File dir = new File(); // I want to use fc.getName() as argument there
  </code></pre>
  
  <p>I'd like to access fc.getName() from the second method, inside a different button. Any suggestions? Thanks in advance!</p>