View the step-by-step solution to:

import java.FlowLayout; import java.event.MouseEvent; import java.event.MouseListener; import javax.swing.JButton; import javax.swing.JFrame; import...

import java.awt.FlowLayout;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JTextArea;

import javax.swing.border.EtchedBorder;

public class EnglishtoPigLatin {

//Defines the components

JTextArea englishArea;

JTextArea pigLatinArea;

JButton convertButton;


public EnglishtoPigLatin(JFrame frame) {

FlowLayout layout = new FlowLayout();

//Create the JTextArea

englishArea = new JTextArea("English Text Here");

pigLatinArea = new JTextArea();

//Set rows and columns



// set the border of the JTextArea

englishArea.setBorder(new EtchedBorder());

//Sets number of rows and columns



//Sets the border of the JTextArea

pigLatinArea.setBorder(new EtchedBorder());

convertButton = new JButton("Convert");

//this line Adds a MouseListener to the JButton

convertButton.addMouseListener(new MouseListener() {

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e) {

String english = englishArea.getText();

if(english.length() < 1 || english.equalsIgnoreCase("English Text Here"))


pigLatinArea.setText("Enter something in the English Text area first");








public void mouseExited(MouseEvent e) {}

public void mouseEntered(MouseEvent e) {

// TODO Auto-generated method stub


public void mouseClicked(MouseEvent e) {}








public static String convertToPigLatin(String target)


String result = "";


if("aeiou".contains(target.substring(0, 1)))


// if it is a vowel then add 'way' to the end

result += target + "way";




result += target.substring(1) +target.charAt(0)+ "ay";


return result;


public static void main(String[] args) {

JFrame frame = new JFrame("English To Pig Latin Converter");

//Create an object of the EnglishToPigLatin

EnglishtoPigLatin converter = new EnglishtoPigLatin(frame);


frame.setSize(500, 100);

//Make the frame visible





Please help me change JTextArea so it shows more rows of text. Also add a BorderLayout at least once to get buttons aligned below your text areas. 

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question