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

Assignment due in 4 hours Reading: Review lecture material and examples posted i

ID: 3592881 • Letter: A

Question

Assignment due in 4 hours

Reading: Review lecture material and examples posted in the class website related to GUI development. Also, check the GUI activity 2 solutions posted.

Assignment Description: 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.

Input textarea Results textField Text Processor Analysis Results Analysis Type OSmall Medium Large Word Count Character Count L Vowel Count Analysis type selection check boxes Font size change radio buttons

Explanation / Answer

import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; import java.util.*; public class Texteditor extends JFrame implements ActionListener { MenuBar mbar; Menu file,edit,format,font,font1,font2; MenuItem item1,item2,item3,item4; MenuItem item5,item6,item7,item8,item9,item10; MenuItem fname1,fname2,fname3,fname4; MenuItem fstyle1,fstyle2,fstyle3,fstyle4; MenuItem fsize1,fsize2,fsize3,fsize4; JPanel mainpanel; TextArea text; Font f; String months[]={ "Jan","Feb","Mar","Apr", "May","Jun","Jul","Aug", "Sep","Oct","Nov","Dec"}; GregorianCalendar gcalendar; String command=" "; String str=" "; String str1=" ",str2=" ",str3=" "; String str4=" "; String str6=" "; String str7=" ",str8=" ",str9=" "; int len1; int i=0; int pos1; int len; public Texteditor(String str) { super(str); mainpanel=new JPanel(); mainpanel=(JPanel)getContentPane(); mainpanel.setLayout(new FlowLayout()); mbar=new MenuBar(); setMenuBar(mbar); file=new Menu("File"); edit=new Menu("Edit"); format=new Menu("Format"); font=new Menu("Font"); font1=new Menu("Font Style"); font2=new Menu("Size"); file.add(item1=new MenuItem("New...")); file.add(item2=new MenuItem("Open")); file.add(item3=new MenuItem("Save As...")); file.add(item4=new MenuItem("Exit")); mbar.add(file); edit.add(item5=new MenuItem("Cut (Ctrl+X)")); edit.add(item6=new MenuItem("Copy (Ctrl+C)")); edit.add(item7=new MenuItem("Paste (Ctrl+V)")); edit.add(item8=new MenuItem("Delete")); edit.add(item10=new MenuItem("Select All (Ctrl+A)")); edit.add(item9=new MenuItem("Time/Date")); mbar.add(edit); format.add(font); format.add(font1); format.add(font2); font.add(fname1=new MenuItem("Courier")); font.add(fname2=new MenuItem("Sans Serif")); font.add(fname3=new MenuItem("Monospaced")); font.add(fname4=new MenuItem("Symbol")); font1.add(fstyle1=new MenuItem("Regular")); font1.add(fstyle2=new MenuItem("Bold")); font1.add(fstyle3=new MenuItem("Italic")); font1.add(fstyle4=new MenuItem("Bold Italic")); font2.add(fsize1=new MenuItem("12")); font2.add(fsize2=new MenuItem("14")); font2.add(fsize3=new MenuItem("18")); font2.add(fsize4=new MenuItem("20")); mbar.add(format); item1.addActionListener(this); item2.addActionListener(this); item3.addActionListener(this); item4.addActionListener(this); item5.addActionListener(this); item6.addActionListener(this); item7.addActionListener(this); item8.addActionListener(this); item9.addActionListener(this); item10.addActionListener(this); fname1.addActionListener(this); fname2.addActionListener(this); fname3.addActionListener(this); fname4.addActionListener(this); fstyle1.addActionListener(this); fstyle2.addActionListener(this); fstyle3.addActionListener(this); fstyle4.addActionListener(this); fsize1.addActionListener(this); fsize2.addActionListener(this); fsize3.addActionListener(this); fsize4.addActionListener(this); text=new TextArea(26,60); mainpanel.add(text); f=new Font("Monotype Corsiva",Font.PLAIN,15); text.setFont(f); } public void actionPerformed(ActionEvent ae) { command=(String)ae.getActionCommand(); if(command.equals("New...")) { dispose(); Texteditor note1 = new Texteditor("Untitled-Notepad"); note1.setSize(500,500); note1.setVisible(true); } try { if(command.equals("Open")) { str4=" "; FileDialog dialog=new FileDialog(this,"Open"); dialog.setVisible(true); str1=dialog.getDirectory(); str2=dialog.getFile(); str3=str1+str2; File f=new File(str3); FileInputStream fobj=new FileInputStream(f); len=(int)f.length(); for(int j=0;j
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