Text Areas

Try out this panel to see how you can use a JTextArea.

import javax.swing.*;
   import java.awt.*;
   import java.awt.event.*;
   * @author (Mrs-O-C)
   * @version (2018)
 public class PanelTextArea extends JPanel
   private JLabel label; 		//output field
   private JTextArea bigbox;

   public PanelTextArea()
     label = new JLabel(" ");
     label.setFont(new Font("Serif", Font.PLAIN, 14));
     bigbox = new JTextArea(" ",3,25);                        // 3 rows and 25 columns
     bigbox.setFont(new Font("Serif", Font.PLAIN, 14));
     bigbox.setLineWrap(true);                                // if lines are long, wrap them around
     bigbox.setWrapStyleWord(true);                           // divide lines between words

	  JButton button = new JButton("View sentences");   
button.addActionListener(new Listener());
add(button); } private class Listener implements ActionListener { public void actionPerformed(ActionEvent e) { label1.setText("Your sentence can go here on a label for output but if it is long will it fit on the label?"); bigbox.setText("Your sentence can go here on a text area for output but if it is long will it fit on the text area?"); } } }