Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is an assignment for my java class, I\'m having quite a bit of trouble maki

ID: 3591665 • Letter: T

Question

This is an assignment for my java class, I'm having quite a bit of trouble making the individual classes for the textarea/ textfield and the buttons, please help. During this homework, you will be designing and implementing a simple text processor application. As shown in the screenshot below, the left hand side TextArea (while is scrollable), allows the user to either type of copy and paste the text to be processed. Your text processor allows the user the change the font size of the text based on the Radio button selections. As the user is selecting the appropriate font size button, the textArea will change font size of the text. Large is selected by default Analysis can be done in three ways, word count, vowel count, and character count. The analysis type is given as check boxes. The user can select one, two, or all three analysis types. As, the user select this option, the analysis results textField shows the analysis results. Note: You can use a suitable layout such as BorderLayout, GridLayout, and combinations of them in your implementation. Each part must be made into individual classes. Below is a picture of what he is asking for.

Input textarea Results textField Text Processor- Analysis Results rSize Analysis Type Small O Medium ® Large Word Count character count i Vowel Count Analysis type selection check boxes Font size change radio buttons

Explanation / Answer

import java.awt.*;
import java.awt.GridLayout;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Color;


public class TextDemo
{

JTextArea jta;
JTextArea jtf;
JFrame jf;

JPanel jp1, jp2, jp3, jp4, main;

JCheckBox wc;
JCheckBox cc;
JCheckBox vc;

JRadioButton sm;
JRadioButton med;
JRadioButton lar;

Font smF;
Font medF;
Font larF;

JScrollPane scrollPaneTa;
JScrollPane scrollPaneTf;

ButtonGroup group;

String res = "";




TextDemo()
{

group = new ButtonGroup();

smF = new Font("serif", Font.PLAIN,5);
medF = new Font("serif", Font.PLAIN,10);
larF = new Font("serif", Font.PLAIN,20);

jf = new JFrame();

jp1 = new JPanel();
jp2 = new JPanel();
jp3 = new JPanel();
jp4 = new JPanel();
main = new JPanel();

jta = new JTextArea(10, 20);

wc = new JCheckBox("Word Count");
cc = new JCheckBox("Character Count");
vc = new JCheckBox("Vowel Count");

sm = new JRadioButton("Small");
med = new JRadioButton("Medium");
lar = new JRadioButton("Large");

jtf = new JTextArea(6, 20);
jtf.setEditable(false);

group.add(sm);
group.add(med);
group.add(lar);

jta.setEditable(true);

scrollPaneTa = new JScrollPane(jta);
scrollPaneTf = new JScrollPane(jtf);
main.setLayout(new GridLayout(2,2));

jp1.add(jta);
jp2.add(jtf);

jp3.add(sm);
jp3.add(med);
jp3.add(lar);
jp4.add(wc);
jp4.add(cc);
jp4.add(vc);

main.add(jp1);
main.add(jp2);
main.add(jp3);
main.add(jp4);

jf.add(main);
jf.setSize(800, 400);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);


sm.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{jta.setFont(smF);}});

med.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{jta.setFont(medF);}});

lar.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{jta.setFont(larF);}});

wc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{wordCount(jta.getText());jtf.setText(res);}});

cc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{characterCount(jta.getText());jtf.setText(res);}});

vc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{vowelCount(jta.getText());jtf.setText(res);}});}
void wordCount(String st)
{int wCounter = 1;for(int c = 0; c < st.length(); c++)
{
if(st.charAt(c) == ' ')
wCounter++;
}
res += " Number of words: " + wCounter;
}
void characterCount(String st)
{
int cCounter = 0;
for(int c = 0; c < st.length(); c++)
{
cCounter++;
}
res += " Number of characters: " + cCounter;
}
void vowelCount(String st)
{
int vCounter = 0;
for(int c = 0; c < st.length(); c++)
{
if

(st.charAt(c) == 'a' || st.charAt(c) == 'A'
|| st.charAt(c) == 'e' || st.charAt(c) == 'E'
|| st.charAt(c) == 'i' || st.charAt(c) == 'I'
|| st.charAt(c) == 'o' || st.charAt(c) == 'O'
|| st.charAt(c) == 'u' || st.charAt(c) == 'U')
vCounter++;
}
res += " Number of vowels: " + vCounter;
}
public static void main(String[] args)
{
new TextDemo();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote