CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Wei Cui
Level 39
Newark
  • 08.04.2020
  • 662views
  • 1comment

where am i wrong

Question about the task HTML Editor (part 7)
Java Multithreading,  Level 8,  Lesson 15
Under discussion

Add a MenuHelper class. This will be a helper class for initializing and configuring the menu.
The menu will have the following structure:
- File
-- New
-- Open
-- Save
-- Save as...
-- Exit

- Edit
-- Undo
-- Redo
-- Cut
-- Copy
-- Paste

- Style
-- Bold
-- Underline
-- Italic
-- Subscript
-- Superscript
-- Strikethrough

- Align
-- Left
-- Center
-- Right

- Color
-- Red
-- Orange
-- Yellow
-- Green
-- Blue
-- Cyan
-- Magenta
-- Black

- Font
-- Font
--- SansSerif, Serif, Monospaced, Dialog, DialogInput,
-- Font size
--- 6, 8, 10, 12, 14, 16, 20, 24, 32, 36, 48, 72

- Help
-- About

7.1. In MenuHelper, implement a static JMenuItem addMenuItem(JMenu parent, String text, ActionListener actionListener) method, where parent is the menu that we're adding the item to, text is the text of the item being added, and actionListener is the action listener of the added menu item. It must:
7.1.1. Use the text parameter to create a new JMenuItem.
7.1.2. Using the addActionListener() method to set an action listener on this item.
7.1.3. Add the created menu item to parent.
7.1.4. Return the created menu item.
7.2. Implement a static JMenuItem addMenuItem(JMenu parent, Action action) method. This method is similar to the previous one, but it has an action parameter, which represents the action that must be performed when the menu item is selected.

Hint: Pass action to the constructor when creating a JMenuItem. Figure out where the name of the menu item will come from if it isn't set separately.
7.3. Implement a static JMenuItem addMenuItem(JMenu parent, String text, Action action) method that adds a new menu item with the text and action arguments to parent when this menu item is selected. In the implementation, call the method in the previous step.
7.4. Add stubs for the following static methods to MenuHelper:
7.4.1. void initHelpMenu(View view, JMenuBar menuBar) - This method initializes the help menu.
7.4.2. void initFontMenu(View view, JMenuBar menuBar) - This method initializes the font menu.
7.4.3. void initColorMenu(View view, JMenuBar menuBar) - This method initializes the color menu.
7.4.4. void initAlignMenu(View view, JMenuBar menuBar) - This method initializes the alignment menu.
7.4.5. void initStyleMenu(View view, JMenuBar menuBar) - This method initializes the style menu.
7.4.6. void initEditMenu(View view, JMenuBar menuBar) - This method initializes the edit menu.
7.4.7. void initFileMenu(View view, JMenuBar menuBar) - This method initializes the file menu.

Requirements:
  • The MenuHelper class must be in a separate file.
  • The MenuHelper class must implement a public static JMenuItem addMenuItem(JMenu parent, String text, ActionListener actionListener) method.
  • The MenuHelper class must implement a public static JMenuItem addMenuItem(JMenu parent, Action action) method.
  • The MenuHelper class must implement a public static JMenuItem addMenuItem(JMenu parent, String text, Action action) method.
  • The MenuHelper class must have a public static void initHelpMenu(View view, JMenuBar menuBar) method.
  • The MenuHelper class must have a public static void initFontMenu(View view, JMenuBar menuBar) method.
  • The MenuHelper class must have a public static void initColorMenu(View view, JMenuBar menuBar) method.
  • The MenuHelper class must have a public static void initAlignMenu(View view, JMenuBar menuBar) method.
  • The MenuHelper class must have a public static void initStyleMenu(View view, JMenuBar menuBar) method.
  • The MenuHelper class must have a public static void initEditMenu(View view, JMenuBar menuBar) method.
  • The MenuHelper class must have a public static void initFileMenu(View view, JMenuBar menuBar) method.
package com.codegym.task.task32.task3209; import javax.swing.text.html.HTMLDocument; import java.io.File; public class Controller { private View view; private HTMLDocument document; private File currentFile; public Controller(View view) { this.view = view; } public void init() {} public void exit() { System.exit(0); } public static void main(String[] args) { View view = new View(); Controller controller = new Controller(view); view.setController(controller); view.init(); controller.init(); } public static class ExceptionHandler { public static void log(Exception e) { } } }
0
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Wei Cui
Level 39 , Newark, United States
8 April 2020, 21:56
JMenuItem menuItem = new JMenuItem(action);
tiny issue
+1
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.