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
  • 753views
  • 3comments

TIPS FOR VIEW CONSTRUCTOR

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

9.1. Implement the initMenuBar() method. It must:
9.1.1. Create a new JMenuBar object. This will be our menu bar.
9.1.2. Use MenuHelper to initialize the menu in the following order: File, Edit, Style, Align, Color, Font, and Help.
9.1.3. Add our menu bar to the top of the current frame's content pane, similar to the way we did this with the tabbed pane.
9.2. Add a View class constructor. It should give our application the same look and feel that are defined in the system.
The constructor must not throw exceptions. It should just log them using ExceptionHandler.

Hint: To implement this task, use the UIManager class.

Run the application. Now you should see a menu bar at the top of the window. Some of the menu items (for example: Cut, Copy, Paste, Style (partially), Align, Color, Font) should already work. Be sure everything works and then continue developing the program.

Requirements:
  • The initMenuBar() method must created a new menu (JMenuBar object).
  • The initMenuBar() method must use MenuHelper to initialize the menu in the following order: File, Edit, Style, Align, Color, Font, and Help.
  • In the initMenuBar() method, the getContentPane() method should be used to add the newly created menu to the top of the current frame's content pane.
  • The View class constructor must use the UIManager class to set the look and feel.
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) { } } }
+2
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
KIN SOCHEAT
Level 34 , Phnom Penh, Cambogia
19 July 2020, 02:10
UIManager.setLookAndFeel(new MetalLookAndFeel());
+2
Satya Vath
Level 31 , Vijayawada, India
14 April 2020, 08:52
public View(){
        try {
            UIManager.setLookAndFeel(View.class.getName());
        }
        catch (Exception f){

        }
    }
Use This
0
Surya
Level 33 , Newark, United States
24 July 2020, 19:55
FYI, This worked for me. UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
+2
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.