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

Write an application with menu bar to process Random-Access File. The menu bar i

ID: 3559857 • Letter: W

Question

Write an application with menu bar to process Random-Access File. The menu bar is created with JFrame. There are three menu options: File, Process,and About. The File menu has three options: New,Open,and Exit. The Process menu has two options: Edit and List. The Edit option has three options: Insert, Delete,and Update. The About menu is to display a message box.

The New option displays a Save Dialog for the user to choose where to save the new data file of 100 empty records.

The Open option displays an Open Dialog for the user to choose which data file to open.

The Insert option allows the user to insert a new record into the data file.

The Delete option allows the user to delete a record from the data file.

The Update option allows the user to update a record in the data file.

The List option allows the user to list all the records from the data file into the JTextArea.

The Random-Access Data File keeps the inventory of a hardware store. The file stores the part number (or record number between 1 to100), the tool name, the quantity on hand, and the cost of each tool. The sample data file is:

Explanation / Answer

//BASKETBALL SKELETON// package Basketball; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Basketball extends JFrame { private final Color colorValues[] = { Color.black, Color.blue, Color.red, Color.green }; private JRadioButtonMenuItem colorItems[], fonts[]; private JCheckBoxMenuItem styleItems[]; private JLabel displayLabel; private ButtonGroup fontGroup, colorGroup; private int style; // set up GUI public Basketball() { super( "BBGS SOFTWARE" ); // set up team menu and its menu items JMenu teamMenu = new JMenu( "Team" ); // set up Add team menu item JMenuItem addTeam = new JMenuItem( "Add" ); teamMenu.add( addTeam ); addTeam.addActionListener( new ActionListener() { // anonymous inner class public void actionPerformed( ActionEvent event ) { new WriteRF(); } } ); JMenuItem editTeam = new JMenuItem( "Edit Team" ); teamMenu.add( editTeam ); editTeam.addActionListener( new ActionListener() { // anonymous inner class // display message dialog when user selects About... public void actionPerformed( ActionEvent event ) { } } // end anonymous inner class ); // end call to addActionListener JMenuItem deleteTeam = new JMenuItem( "Delete Team" ); teamMenu.add( deleteTeam ); deleteTeam.addActionListener( new ActionListener() { // anonymous inner class // display message dialog when user selects About... public void actionPerformed( ActionEvent event ) { } } // end anonymous inner class ); // end call to addActionListener // set up List team menu item JMenuItem listTeam = new JMenuItem( "View Teams" ); teamMenu.add( listTeam ); listTeam.addActionListener( new ActionListener() { // anonymous inner class // display message dialog when user selects About... public void actionPerformed( ActionEvent event ) { new ReadRF(); } } // end anonymous inner class ); // end call to addActionListener // create menu bar and attach it to Basketball window JMenuBar bar = new JMenuBar(); setJMenuBar( bar ); bar.add( teamMenu ); // set up teamship menu and its menu items JMenu teamshipMenu = new JMenu( "Game" ); // set up Add team menu item JMenuItem addGame = new JMenuItem( "Add Game" ); teamshipMenu.add( addGame ); addGame.addActionListener( new ActionListener() { // anonymous inner class // display message dialog when user selects About... public void actionPerformed( ActionEvent event ) { JOptionPane.showMessageDialog( Basketball.this, "Add a Game", "Adding", JOptionPane.PLAIN_MESSAGE ); } } ); JMenuItem editGame = new JMenuItem( "Edit/Delete Game" ); teamshipMenu.add( editGame ); editGame.addActionListener( new ActionListener() { // anonymous inner class // display message dialog when user selects About... public void actionPerformed( ActionEvent event ) { JOptionPane.showMessageDialog( Basketball.this, "Edit a Game", "Editing", JOptionPane.PLAIN_MESSAGE ); } } // end anonymous inner class ); // end call to addActionListener // set up List team menu item JMenuItem listGame = new JMenuItem( "List Games" ); teamshipMenu.add( listGame ); listGame.addActionListener( new ActionListener() { // anonymous inner class // display message dialog when user selects About... public void actionPerformed( ActionEvent event ) { JOptionPane.showMessageDialog( Basketball.this, "Lisiting Games", "View", JOptionPane.PLAIN_MESSAGE ); } } // end anonymous inner class ); // end call to addActionListener // create menu bar and attach it to Basketball window bar.add( teamshipMenu ); // set up Exit menu item JMenu exitMenu = new JMenu( "Exit" ); exitMenu.addActionListener( new ActionListener() { // anonymous inner class // terminate application when user clicks exitItem public void actionPerformed( ActionEvent event ) { System.exit( 0 ); } } // end anonymous inner class ); // end call to addActionListener bar.add( exitMenu ); displayLabel = new JLabel( "Welcome", SwingConstants.CENTER ); displayLabel.setForeground( colorValues[ 0 ] ); displayLabel.setFont( new Font( "Serif", Font.PLAIN, 52 ) ); //getContentPane().setBackground( Color.CYAN ); getContentPane().add( displayLabel, BorderLayout.PAGE_END ); setSize(800, 600 ); setLocation(200, 240); setVisible( true ); } public static void main( String args[] ) { Basketball application = new Basketball(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } } // end class Basketballs

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote