How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask ATLProg Your Own Question

ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 9148
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
Type Your Homework Question Here...
ATLProg is online now
A new question is answered every 9 seconds

JAVA program (Net Beans) Create frame from JFrame Design

This answer was rated:

JAVA program (Net Beans)
Create frame from JFrame

Design a class called MyJFrame to produce output as shown in Figures 1 – 7. This frame must be inherited from the class JFrame. The frame must contain only a title as shown in Figure 1

Figure 1

Create a menu bar object and set it in place. Add menu choices onto the menu bar as shown in Figure 2.

Figure 2

Add menu items to each menu choice as shown in Figure 3 and Figure 4. Place separators where indicated in the Figures.

Figure 3

For the menu choice Tools, create a cascading menu for the menu choice Edit. This submenu must contain menu items as shown in the Figure 4.

Figure 4

The following is an outline of the code for the class MyJFrame. You may consult your notes and class handouts for further information.

1. Use an interface to maintain constant values and generic methods
2. Use arrays to contain:
(a) The list of menu choices
(b) The list of menu items for the menu choices – File, Tool, and Edit.

// Area reserve for importing classes.

class MyJFrame extends JFrame
JMenuBar mbar;
JMenu jm;
JMenuItem mi;

MyJFrame(String title)

mbar = new JMenuBar(); //Create menu bar and set it

buildMenu(); // Call method which actually builds the menu

void buildMenu()
for (int i = 0; i <Constants. MENU.length; i++) // For each menu choice, create a menu choice object
jm = new JMenu(Constants.MENU);

/* Determine the menu choice and create menu items for each menu
* choice and add each set of menu items to its respective menu choice
case 0: // File
//Create separator or create file menu item and add each to the menu choice


case 1: //Tool
/* First, check for the string Edit. When found, use it to create a sub menu
object. Next, create menu items, in this case – Copy and Paste as menu
items. Add these menu items to the sub menu. Finally, add this sub menu to
the menu choice Tool.
If the string is not Edit, then it must be a menu item for menu choice Tool.
Create each menu item objects, in this case – Sort and Search, and add each
to the menu choice Tool.


case 2: // Help, at this point no menu item will be attached

default: // No action taken at this time
}// End switch
mbar.add(jm); // Add each menu choice with its menu items to the menu bar.
}// End for
}// End build
}// End class MyJFrame

Part II

Additing Functionality to your GUI

Create an anonymous WindowListener class such that when you click the close button on your frame, a child frame (JOptionPane frame) appears, similar to Figure 5 Remember to import the class WindowAdapter and the class WindowEvent.

Figure 5

Go to the class MyJFrame and register each menu item to the ActionListener object. The general format is:

mi.addActionListener(new Actions());

where the class Actions is partially defined below

The class Actions determines which menu item has been activated. The general format of this class is as follows:

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

class Actions implements ActionListener
DisplayText dt;

public void actionPerformed(ActionEvent e)
if (e.getActionCommand().equalsIgnoreCase("New"))
dt = new DisplayText("Untitled..... ", "");
else if(e.getActionCommand().equalsIgnoreCase("Open"))
BasicFile f = new BasicFile();
dt = new DisplayText(f.getName(), f.getContent());


(b) Implement the class DisplayText that was given to you. This class accepts two strings - the first represents the name of a file and the second string, the contents of the file. This class constructs a frame object from the class MyJFrame accepts the first string which is used as a title. Place the second string is the text to be displayed in a JScrollPane.

(c) Use the class called BasicFile from Assignment 4. This file uses the FileChooser class to create a File dialog. At this point the three most important methods are:
• selectFile() which creates the file dialog, from which you can select a file.
• getName() returns the name of the file you selected
• getContents() returns the contents of the file you selected.

Running the Program

When you run the program and select File – New, your output should be similar to Figure 6.

Figure 6

Similarly, when you select File – Open, your output should be similar to Figure 7.

Figure 7

This should be familiar to you. If you select a file its contents would be displayed as shown in Figure 8.

Figure 8

• Implement the Copy - Paste options. That is use the mouse to highlight a portion of the displayed text, and copy it to a different location in the document.

Part III
Adding buttons to the frame.
Hello welcome i can assist you with your program. I am ATLProg
Can you please let me know by when you need this done?
Customer: replied 3 years ago.

It must be completed by: Wednesday April 24th by 11:00 PM


Can you please send me a pdf/word document/URL of your assignment description ?
Can you please send me the files you have been working with ?
Can you please go to and upload your file ? Once you do that you will get a page that has the "Download Link". Copy the "Download Link" and please paste it in your reply here.
Customer: replied 3 years ago.

link with assignment instructions:


link with files i have been working with:


ok let me seee
I have sent a Underpriced report on this to your registered email id, please confirm if the price looks ok to you. Please let me know so I can start working on this accordingly.
Customer: replied 3 years ago.

The price looks okay to me.


You need to spend $3 to view this post. Add Funds to your account and buy credits.
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 9148
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
ATLProg and 3 other Homework Specialists are ready to help you
Did it work ? Do you have any questions ? Concerns ?
Please add the difference of amounts as agreed upon per underpriced report as bonus/tip when you Rate answer. You should see a button add bonus/tip .

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Previous | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX

Meet The Experts:

  • LogicPro



    Satisfied Customers:

    Expert in Java C++ C C# VB Javascript Design SQL HTML
< Last | Next >
  • LogicPro's Avatar



    Satisfied Customers:

    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany


    Satisfied Customers:

    More than 5000 online tutoring sessions.
  • Linda_us's Avatar


    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    Post Graduate Diploma in Management (MBA)
  • Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    Experience with chartered accountancy
  • Bizhelp's Avatar



    Satisfied Customers:

    Bachelors Degree and CPA with Accounting work experience
  • Seanna's Avatar



    Satisfied Customers:

    3,000+ satisfied customers, all topics, A+ work

Related Homework Questions