title: how to print something to jtextfield if i have condition
body: <p>I have an array (<code>logic.res</code>) where I stored the results of some calculations, and I want to print on a <code>JTextarea (rez)</code> a result (an element of that array). I want to insert before that result a single sentence. Which sentence is chosen depends on which element of that array is the result (<code>i</code> determines the result):</p>
  
  <pre><code> public void initComponents() {
  calculate.addActionListener((ActionEvent p) -&gt; {
  
          try {
              if (radioButton1.isSelected()) {
                  double condition1 = Double.parseDouble(txtCondition1.getText());
                  double condition2 = Double.parseDouble(txtConition2.getText());
                  double condition3 = Double.parseDouble(txtCondition3.getText());
                  double[] conditions = {condition1, condition2, condition3};
                  double shift1 = Double.parseDouble(txtShift1.getText());
                  double shift2 = Double.parseDouble(txtShift2.getText());
                  double shift3 = Double.parseDouble(txtShift3.getText());
                  double workingDays = 360;
                 YearWorkingHurs yearWorkingHours = new YearWorkingHurs(workingDays);
                  double[] shifts = {shift1, shift2, shift3};
                  double capacity1 = object.getCapacity();
                  double capacity2 = object2.getCapacity();
                  Logic logic = new Logic(capacity1, capacity2, conditions, shifts);
                  logic.solution();
                  long[] solution = logic.rez;
                  for (int i = 0; i &lt; logic.rez.length; i++) {long[] solution = logic.res;
          for (int i = 0; i &lt; logic.res.length; i++) {
              if (logic.res[i] &gt;= 20000000 &amp;&amp; logic.res[i] &lt; 23000000) {
  
                  long temp = logic.res[i];
                  if (i == 0) {
                      rez.append("The choosen capacity has been fulfilled in good condition in one shift" + "\n");
                      rez.append(String.valueOf(temp) + "\n");                                        
                      draw.setEnabled(true);
                  } else if (i == 1) {
                      rez.append("The choosen capacity has been fulfilled in good condition in 2 shifts" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 2) {
                      rez.append("The choosen capacity has been fulfilled in good condition in 3 shifts" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 3) {
                      rez.append("The choosen capacity has been fulfilled in semi-good condition in one shift" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 4) {
                      rez.append("The choosen capacity has been fulfilled in semi-good condition in 2 shifts" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 5) {
                      rez.append("The choosen capacity has been fulfilled in semi-good condition in 3 shifts" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 6) {
                      rez.append("The choosen capacity has been fulfilled in bad condition in one shift" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 7) {
                      rez.append("The choosen capacity has been fulfilled in bad condition in 2 shifts" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
                      draw.setEnabled(true);
                  } else if (i == 8) {
                      rez.append("The choosen capacity has been fulfilled in bad condition in 3 shifts" + "\n");
                      rez.append(String.valueOf(temp) + "\n");
  
                  }
  
              } else {
  
              }
          }
  
      }
  
  
      }catch(Exception ex){
                  JOptionPane.showMessageDialog(rootPane,"Greska u proračunu,proverite unose");
                 }
  
              obrisi.setEnabled(true);
          });
  </code></pre>
  
  <p>But with this code I didn't get the desired sentence, because this is both referencing to the number of elements in my array, and to the number of lines in my <code>JTextArea</code>. </p>
  
  <p>The text that I want to get in my <code>JTextArea</code> is, for example, the result that is in the 8th element of the array, but because it is printed in line 3, it got the sentence from <code>i==3</code> instead of <code>i==8</code>.</p>