Question: Complete exercise 14.7. // Exercise 14.7 : PigLatin.java // Application translates English to Pig Latin. import javax.swing.JFrame; public class PigLatin{ public static void main(String[] args)

Complete exercise 14.7.

// Exercise 14.7 : PigLatin.java

// Application translates English to Pig Latin.

import javax.swing.JFrame; public class PigLatin{

public static void main(String[] args) {

// create PigLatinFrame object

//set default close operation

//set frame size(400, 200)

//display frame

}

} // end class PigLatin

//Exercise 14.7: PigLatinFrame.java

// Application translates English to Pig Latin.

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.Scanner;

import javax.swing.JFrame;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.JTextField;

public class PigLatinFrame extends JFrame{

// create JTextField for entering sentences to be converted

// create JTextArea to log converted pig Latin phrases

public PigLatinFrame() {

super("Pig Latin Conversion");

// create input text field

// add event handler

// anonymous inner class

{

public void actionPerformed(ActionEvent e) {

//get input text and convert the phrase

//clear input text

}

}

//close event handler

// create output text area

// do not allow output text area to be editable // set layout

//add input component

//add scroll pane component to allow scrolling

} // convert a phrase to pig Latin and display it

private void convertPhrase(String phrase) {

// translate user input // print words converted to pig Latin one at a time

for (String word : words)

// print latin word // add newline to output

} // convert a single word to pig Latin and add to output text area

private void printLatinWord(String word) {

output.append(word.substring(1));

// append first character of output to lower case

output.append("ay ");

}

} // end class PigLatin

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!