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

Please write in Java swing the program Please write all the codes, textfield,lab

ID: 3711955 • Letter: P

Question

Please write in Java swing the program
Please write all the codes, textfield,label,panel in the TextEditorFrame.java and and this class must JFrame and impliment AcrionListener
Please when setting the JFram constructor use the Superclass method
Please in the TextEditorProgram.Java Only call the TextEditorFrame class dont write codes
See photo for more detailes

Text Editor Program Create a graphical text editor program. The window should only consist of a scrollable text area. The user should have the menu options to create new files and open/save existing files. Your Text Editor’s window size should be 500 pixels wide and 500 pixels tall. How your Text Editor must look (This image has been cropped): • When the program first starts, the window’s text area should be empty. o You can place a text area directly on the frame for this program. o The text area will fill the entire window, so the initial height and width of the text area will not matter. • The text editor must have a menu bar containing a single File menu. • The File menu should have the options of New, Open, Save, and Exit. (See photos) o Menu items should have the mnemonics shown below as well.    • When the user selects the New menu item, the text area should be cleared. • When the user selects the Open menu item, an open file chooser window should appear. o When the user selects their file, the contents of the file should be displayed in the text area. • When the user selects the Save menu item, a save file chooser window should appear. o When the user selects their file, the contents of the text area should be written to the file the user selected. • When the user selects the Exit menu item, the program should end. • The text area should be scrollable but have no word wrapping. Additional Image
Tips • After opening/reading an existing file, be sure to close it. If you leave it open, the user will be unable to overwrite the existing file if it wasn’t closed. • When reading a file, you can build a string that contains the contents of the file, then use that string to set the text area’s text.
Note DO NOT USE A GUI/FORM DESIGNER TOOL TO CREATE THIS PROGRAM   
Text Editor Program Create a graphical text editor program. The window should only consist of a scrollable text area. The user should have the menu options to create new files and open/save existing files. Your Text Editor’s window size should be 500 pixels wide and 500 pixels tall. How your Text Editor must look (This image has been cropped): • When the program first starts, the window’s text area should be empty. o You can place a text area directly on the frame for this program. o The text area will fill the entire window, so the initial height and width of the text area will not matter. • The text editor must have a menu bar containing a single File menu. • The File menu should have the options of New, Open, Save, and Exit. (See photos) o Menu items should have the mnemonics shown below as well.    • When the user selects the New menu item, the text area should be cleared. • When the user selects the Open menu item, an open file chooser window should appear. o When the user selects their file, the contents of the file should be displayed in the text area. • When the user selects the Save menu item, a save file chooser window should appear. o When the user selects their file, the contents of the text area should be written to the file the user selected. • When the user selects the Exit menu item, the program should end. • The text area should be scrollable but have no word wrapping. Additional Image
Tips • After opening/reading an existing file, be sure to close it. If you leave it open, the user will be unable to overwrite the existing file if it wasn’t closed. • When reading a file, you can build a string that contains the contents of the file, then use that string to set the text area’s text.
Note DO NOT USE A GUI/FORM DESIGNER TOOL TO CREATE THIS PROGRAM   
Text Editor Program Create a graphical text editor program. The window should only consist of a scrollable text area. The user should have the menu options to create new files and open/save existing files. Your Text Editor’s window size should be 500 pixels wide and 500 pixels tall. How your Text Editor must look (This image has been cropped): • When the program first starts, the window’s text area should be empty. o You can place a text area directly on the frame for this program. o The text area will fill the entire window, so the initial height and width of the text area will not matter. • The text editor must have a menu bar containing a single File menu. • The File menu should have the options of New, Open, Save, and Exit. (See photos) o Menu items should have the mnemonics shown below as well.    • When the user selects the New menu item, the text area should be cleared. • When the user selects the Open menu item, an open file chooser window should appear. o When the user selects their file, the contents of the file should be displayed in the text area. • When the user selects the Save menu item, a save file chooser window should appear. o When the user selects their file, the contents of the text area should be written to the file the user selected. • When the user selects the Exit menu item, the program should end. • The text area should be scrollable but have no word wrapping. Additional Image
Tips • After opening/reading an existing file, be sure to close it. If you leave it open, the user will be unable to overwrite the existing file if it wasn’t closed. • When reading a file, you can build a string that contains the contents of the file, then use that string to set the text area’s text.
Note DO NOT USE A GUI/FORM DESIGNER TOOL TO CREATE THIS PROGRAM   

Explanation / Answer

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.io.*;

class miniNotepad implements ActionListener

{

boolean flag=false;

JFrame jf,ef,sf;

JMenuBar mb;

JMenu File,Edit,Format,View,Help;

JMenuItem New,Open,Save,Exit;

JTextArea ta;

JTextField tf1,tf2;

JButton btn,btn2;

JScrollPane s;

String data="",filepath=null;

public void setDesign()

{

jf=new JFrame("My Notepad");

jf.setSize(500,500);

ta=new JTextArea(20,20);

s=new JScrollPane(ta,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

jf.add(s);

mb=new JMenuBar();

File=new JMenu("File");

Format=new JMenu("Format");

View=new JMenu("View");

Help=new JMenu("Help");

New=new JMenuItem("New");

Open=new JMenuItem("Open");

Save=new JMenuItem("Save");

Exit=new JMenuItem("Exit");

File.add(New);

File.add(Open);

File.add(Save);

File.add(Exit);

mb.add(File);

mb.add(Format);

mb.add(View);

jf.add(s);

mb.add(Help);

jf.setJMenuBar(mb);

jf.setVisible(true);

jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

New.addActionListener(this);

Open.addActionListener(this);

Save.addActionListener(this);

Exit.addActionListener(this);

}

void editDesign()

{

ef=new JFrame("Edit");

ef.setSize(400,100);

ef.setLayout(new FlowLayout());

tf1=new JTextField(15);

btn=new JButton("Open File");

JLabel Lbl=new JLabel("File Name : ");

ef.add(Lbl);

ef.add(tf1);

ef.add(btn);

ef.setVisible(true);

btn.addActionListener(this);

}

void saveDesign()

{

sf=new JFrame("Save");

sf.setSize(400,100);

sf.setVisible(true);

sf.setLayout(new FlowLayout());

tf2=new JTextField(15);

btn2=new JButton("Save File");

JLabel Lbl1=new JLabel("File Name : ");

sf.add(Lbl1);

sf.add(tf2);

sf.add(btn2);

sf.setVisible(true);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent e)

{

if(e.getActionCommand().equals("New"))

{

ta.setText("");

}

else if(e.getActionCommand().equals("Open"))

{

editDesign();

}

else if(e.getActionCommand().equals("Open File"))

{

String p2=tf1.getText();

filepath=p2;

flag=true;

try

{

FileReader fr=new FileReader(p2);

BufferedReader br=new BufferedReader(fr);

String str=br.readLine();

while(str!=null)

{

data=data+str+" ";

str=br.readLine();

}

br.close();

ef.setVisible(false);

}

catch(Exception ae)

{

ae.printStackTrace();

}

ta.setText(data);

}

else if(e.getActionCommand().equals("Save"))

{

if(filepath!=null)

{

try

{

FileWriter fw=new FileWriter(filepath);

BufferedWriter bw=new BufferedWriter(fw);

char [] d=ta.getText().toCharArray();

for(char c:d)

{

if(c==' ')

{

bw.newLine();

}

else

{

bw.write(c);

}

}

bw.close();

}

catch(Exception ae)

{

ae.printStackTrace();

}

}

else

{

saveDesign();

}

}

else if(e.getActionCommand().equals("Save File"))

{

try

{

FileWriter fw=new FileWriter(tf2.getText());

BufferedWriter bw=new BufferedWriter(fw);

char [] d=ta.getText().toCharArray();

for(char c:d)

{

if(c==' ')

{

bw.newLine();

}

else

{

bw.write(c);

}

}

bw.close();

}

catch(Exception ae)

{

ae.printStackTrace();

}

sf.setVisible(false);

}

else if(e.getActionCommand().equals("Exit"))

{

System.exit(0);

}

}

public static void main(String ar[])

{

new miniNotepad().setDesign();

}

}