title: pass a value obtained from a JButton to a variable
body: <p>so my problem is that i'm making a really simple number guessing game in java swing, i added a JButton and a JTextField, i want to click the button to get the value written in my text field and then pass it to a do while loop that's gonna make the operation, then i'm going to display it in a JLabel, But i don't know how. I have no JFrame cause i'm gonna send this class to the class that has the JFrame, so i'm adding everything to a JPanel.
  hope I was clear, would appreciate some help.</p>
  
  <p>code:</p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  import javax.swing.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class GameDat extends JPanel {
  JPanel panel = new JPanel();
  FlowLayout layout = new FlowLayout();
  Random random = new Random();
  JButton enter;
  JTextField display;
  JLabel result;
  
  int MIN = 1;
  int MAX = 50;
  int compare = random.nextInt(MAX - MIN + 1) + MIN;
  int player;
  int guessIt = 0;
  
  
  public void iniGame(){
  
      enter = new JButton("Pick a number:");
  
      panel.setSize(300,300);
      panel.setLayout(layout);
      panel.add(enter);
      panel.add(display);
      panel.add(result);
  
      enter.addActionListener(new CustomActionListenerEnter());
  
  
        do {
  
       //here should go the value captured from the JTextField instead of a scanner
       player = input nextInt();
       guessIt++;
  
          if (player &gt; compare)
              //this text should go to the jlabel instead of printing it
              System.out.println("Number is less than " + player);
          else if (player &lt; compare)
              //this text should go to the jlabel instead of printing it
               System.out.println("Number is greater than " + player);
          else 
               //this text should go to the jlabel instead of printing it
               System.out.println(compare + " was my number, it took you " + guessIt + " guesses.");
      } while (player != compare);
  }
  
  class CustomActionListenerEnter implements ActionListener{
  
          public void actionPerformed(ActionEvent e){
              //I wanna pass this value to my do while.
              display.getText();
  
  
          }
      }
  
  
  
  }
  </code></pre>