title: i made the gui program for a calculator but i want to show a confirm messgae in java if the value in the textfield is a string
body: <pre><code>public class x extends JFrame implements ActionListener {
      JFrame calc;
      JPanel holder;
      JTextField zzz;
      JLabel updating;
      JButton a, s, m, d, c;
      float input, ans;
      String lol, n;
      boolean f = true;
      JOptionPane p;
  
      public x() {
          ans = 0;
          calc = new JFrame(&quot;CALCULATOR&quot;);
          calc.setLayout(new GridLayout(3, 5));
          calc.setVisible(true);
          calc.setSize(1000, 2000);
  
          holder = new JPanel();
          holder.setLayout(new GridLayout(1, 5));
          holder.setVisible(true);
  
          zzz = new JTextField();
          zzz.addActionListener(this);
  
          updating = new JLabel(ans + &quot; &quot;);
  
  
          a = new JButton(&quot;ADD&quot;);
          a.addActionListener(this);
          a.setEnabled(true);
  
          s = new JButton(&quot;SUBTRACT&quot;);
          s.addActionListener(this);
          s.setEnabled(true);
  
          m = new JButton(&quot;MULTIPLY&quot;);
          m.addActionListener(this);
          m.setEnabled(true);
  
          d = new JButton(&quot;DIVISION&quot;);
          d.addActionListener(this);
          d.setEnabled(true);
  
          c = new JButton(&quot;CLEAR&quot;);
          c.addActionListener(this);
          c.setEnabled(true);
  
          holder.add(a, BorderLayout.WEST);
          holder.add(s, BorderLayout.WEST);
          holder.add(m, BorderLayout.WEST);
          holder.add(d, BorderLayout.WEST);
          holder.add(c, BorderLayout.WEST);
  
          calc.add(updating, BorderLayout.NORTH);
          calc.add(zzz, BorderLayout.NORTH);
          calc.add(holder, BorderLayout.NORTH);
  
      }
  
      @Override
      public void actionPerformed(ActionEvent e) {
          lol = zzz.getText();
          input = Float.parseFloat(lol);
  
          if (e.getSource() == zzz) {
              n = zzz.getText();
  
          } else if (e.getSource() == a) {
  
              ans = input + ans;
              updating.setText(ans + &quot; &quot;);
              zzz.setText(&quot;0 &quot;);
  
          } else if (e.getSource() == s) {
  
              ans = ans - input;
              updating.setText(ans + &quot; &quot;);
              zzz.setText(&quot;0 &quot;);
  
          } else if (e.getSource() == d) {
  
              ans = ans / input;
              updating.setText(ans + &quot; &quot;);
              zzz.setText(&quot; 0&quot;);
  
          } else if (e.getSource() == m) {
  
              ans = input * ans;
              updating.setText(ans + &quot; &quot;);
              zzz.setText(&quot;0 &quot;);
  
          }
  
          if (e.getSource() == c) {
              ans = 0;
              updating.setText(&quot; 0 &quot;);
              zzz.setText(&quot; 0&quot;);
  
          }
  
      }
  
  
  }
  </code></pre>
  <p>I can use option for the message but how can I compare the two values and how to check if entered value is a string
  do i use the textfieldgettext and compare it to float?i tried that but it shows the message each time i type something in the textfield</p>
  <p>i can use option pane and use the confirm message but it shows for each entry i type</p>