title: how to fix key pressed function for changing Jlabel into valid values
body: <p>I'm working with conversion degrees, once user enters value into text field pointing out which degree is needed,  the input with output result should appear instead of the label was before.
     Here section for formatting restriction for letters input only for numbers in the text field</p>
  
  <pre><code>        NumberFormat format = NumberFormat.getInstance();
          NumberFormatter formatter = new NumberFormatter(format);
          formatter.setValueClass(Double.class);
          formatter.setMinimum(Double.MIN_VALUE);
          formatter.setMaximum(Double.MAX_VALUE);
          formatter.setAllowsInvalid(false);
          formatter.setCommitsOnValidEdit(true);
          formattedTextField = new JFormattedTextField(formatter);
  
          formattedTextField.setColumns(10);
  
        }
  </code></pre>
  
  <p>here the problem </p>
  
  <pre><code>      public void keyPressed(KeyEvent e){
          double degree;
          if (Angle.isSelected()||e.getKeyChar()==KeyEvent.VK_ENTER){
            degree = Math.toDegrees((double)formattedTextField.getValue());
            resultLabel.setText(formattedTextField.getValue() 
     + " ° = "+ degree + " radians");
  
    }else if(Radians.isSelected()||e.getKeyChar()==KeyEvent.VK_ENTER){
   degree = Math.toRadians((double) formattedTextField.getValue());
            resultLabel.setText(formattedTextField.getValue() + 
   " radians = " + degree + " °");
          }
        }
      }
  </code></pre>