title: java -- how to make new text block appear every time a button is clicked
body: <p>I'm new at Java and trying to make a simple interactive fiction game with a GUI using swing. Right now I'm trying to break a large block of text into sections so it will fit onto the screen easily. I want one block of text to show in a Jtextarea with a "continue" Jbutton on the bottom of the screen, where every time a user clicks the Jbutton the current text will disappear and be replaced with new text. Here's the relevant code:</p>
  
  <pre><code>    public class forwardScreenHandler implements ActionListener{
      public void actionPerformed(ActionEvent event){
          mainTextArea.setText("Nice change!");
          mainTextArea.setText("do it again!");
          mainTextArea.setText("Please be third!");
  
              }
          }
  
  public void chooseYes(){
      yesnoButtonPanel.setVisible(false);
      continueButtonPanel.setVisible(true);
      continueButtonPanel.setBackground(Color.red);
      continueButton.removeActionListener(contHandler);
      continueButton.addActionListener(userCont);
      position = "yes";
      mainTextArea.setText("Blah Blah Blah");
  
  }
  </code></pre>
  
  <p>Clearly the code will result in "blah blah blah" being initially shown, then when I click the continue button the final setText "Please be third!". I understand it's because I haven't written any code telling Java to setText every time the continue button is clicked, but I can't figure out how to do this. Like I said I'm a beginner, so any explanation would be helpful so I can understand what to do.</p>