title: Java - Access variable from another method in main method
body: <p>This is the full code if anyone can help, I'm basically attempting to make a email availability checker. All I want is too put the variable line into my Jlist so it will output all the emails and be removed from JList if that email has been checked.</p>
  
  <pre><code>   class main{
      public static void main(String[] args) throws InterruptedException {
          gui.gui();
  
      }
  }    
  </code></pre>
  
  <p>|</p>
  
  <pre><code> import org.openqa.selenium.By;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebElement;
      import org.openqa.selenium.chrome.ChromeDriver;
      import java.io.BufferedReader;
      import java.io.FileNotFoundException;
      import java.io.FileReader;
      import java.io.IOException;
  
      class tuna {
          public static void tuna() throws InterruptedException, FileNotFoundException {
              WebDriver driver = new ChromeDriver();
              try (BufferedReader br = new BufferedReader(new FileReader("emails.txt"))) {
                  String line;
  
  
                  while ((line = br.readLine()) != null) {
                      driver.get("https://signup.live.com/signup?wa=wsignin1.0&amp;rpsnv=12&amp;ct=1465840004&amp;rver=6.7.6643.0&amp;wp=&amp;wreply=https%3a%2f%2fwww.msn.com%2fen-us%2fhomepage%2fSecure%2fPassport%3fru%3dhttp%253a%252f%252fwww.msn.com%252f%253focid%253dmailsignout%2526pfr%253d1&amp;id=1184&amp;pcexp=True&amp;bk=1465840005&amp;uiflavor=web&amp;uaid=dc151162984741948b8371ce3e0c865e&amp;mkt=EN-US&amp;lc=1033&amp;lic=1");
                      WebElement Email = driver.findElement(By.id("MemberName"));
                      WebElement Refresher = driver.findElement(By.id("FirstName"));
                      WebElement TakenErrorMsg = driver.findElement(By.id("MemberNameError"));
                      Email.sendKeys(line);
                      Refresher.click();
                      Thread.sleep(650);
                      if (TakenErrorMsg.isDisplayed()) {
                          System.out.println(line + " is taken!");
  
                      } else {
                          System.out.println(line + " is not taken!");
                      }
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
          }
      }
  </code></pre>
  
  <p>|</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.io.FileNotFoundException;
  
  
  public class gui extends JFrame {
      public static void gui() {
  
  
          JLabel label1 = new JLabel("Hotmail availability checker");
          label1.setVisible(true);
          label1.setSize(250, 250);
          label1.setLocation(165, -100);
  
          JLabel label2 = new JLabel("Emails unchecked");
          label2.setVisible(true);
          label2.setSize(250, 240);
          label2.setLocation(40, -82);
  
  
  
  
          JButton b1 = new JButton("Start");
          b1.setSize(200,50);
          b1.setLocation(140, 300);
          b1.setVisible(true);
  
  
          JScrollPane scrollPane = new JScrollPane();
          final DefaultListModel emailsChecked = new DefaultListModel();
          emailsChecked.addElement("AAA");
  
          final JList list = new JList(emailsChecked);
          list.setVisible(true);
          list.setVisible(true);
          list.setLocation(20,50);
          list.setSize(150,200);
          scrollPane.setViewportView(list);
  
  
  
          JFrame frames = new JFrame();
          frames.setTitle("Hotmail availability checker");
          frames.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frames.setLayout(null);
          frames.setVisible(true);
          frames.setSize(500, 400);
          frames.setLocationRelativeTo(null);
          frames.add(b1);
          frames.add(label1);
          frames.add(list);
          frames.add(label2);
          frames.add(scrollPane);
  
  
          b1.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  try {
                      tuna.tuna();
                  } catch (InterruptedException e1) {
                      e1.printStackTrace();
                  } catch (FileNotFoundException e1) {
                      e1.printStackTrace();
                  }
  
  
              }
          });
      }
  }
  </code></pre>