Using Java how do i do the following problem Create a Menu S

Using Java how do i do the following problem?

Create a Menu System for opening and saving information.

The menu bar should contain two titles: File and Options

Under the File Menu, there are two options:

Open a saved file

Save a file

Under the Options Menu, there are two options:

Reset All

Exit File

Open (a Saved Character)

With this option, you should be able to open a saved file, for example, Bob.player or Sue.player

The character’s information will be read into the program and all the components on the GUI will be set accordingly, as if the user had just entered them. If the user makes changes, these changes should overwrite the current file (upon a save.)

File Save

This option allows the user to save the current information he/she is working on. The file will contain information that represents the state of the GUI and must be readable by the Open option. The file must be saved as character_name.player that is created from a TextField.

You should prompt the user and say “Are you sure you want to save this charcter?” before they actually save it. Your dialog prompt should allow the user to Cancel the save if he/she so desires.

Reset All

Reset All sets all the GUI components to their zero state. Note that this option does not automatically save the character data.  

Exit

This is self-explanatory. Close the Character Creation application.

Solution

import java.awt.EventQueue;

import java.awt.event.ActionEvent;

import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;

import javax.swing.JFrame;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

public class SimpleMenuEx extends JFrame {

    public SimpleMenuEx() {

        initUI();

    }

    private void initUI() {

       

        createMenuBar();

        setTitle(\"Simple menu\");

        setSize(300, 200);

        setLocationRelativeTo(null);

        setDefaultCloseOperation(EXIT_ON_CLOSE);

    }

    private void createMenuBar() {

        JMenuBar menubar = new JMenuBar();

        ImageIcon icon = new ImageIcon(\"exit.png\");

        JMenu file = new JMenu(\"File\");

        file.setMnemonic(KeyEvent.VK_F);

        JMenuItem eMenuItem = new JMenuItem(\"Exit\", icon);

        eMenuItem.setMnemonic(KeyEvent.VK_E);

        eMenuItem.setToolTipText(\"Exit application\");

        eMenuItem.addActionListener((ActionEvent event) -> {

            System.exit(0);

        });

        file.add(eMenuItem);

        menubar.add(file);

        setJMenuBar(menubar);

    }

    public static void main(String[] args) {

        EventQueue.invokeLater(() -> {

            SimpleMenuEx ex = new SimpleMenuEx();

            ex.setVisible(true);

        });

    }

}

Using Java how do i do the following problem? Create a Menu System for opening and saving information. The menu bar should contain two titles: File and Options
Using Java how do i do the following problem? Create a Menu System for opening and saving information. The menu bar should contain two titles: File and Options

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site