Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a Java code with GUI(Graphical User Interface) Assignment # 2 Binary I/O Objective: Reading/Writing information in Binary format to file sequentially i.e., using DataInput/DataOutput

write a Java code with GUI(Graphical User Interface)

Assignment # 2 Binary I/O

Objective:

Reading/Writing information in Binary format to file sequentially i.e., using DataInput/DataOutput Streams

Using exception handling

GUI Design and Event Handling

Instructions:

Late assignments will be penalized with 5% per day. Assignment more than 2 days will not be accepted and graded.

Create a zip file of your project and submit the solution.

You should prepare TWO videos, one to demo the execution and the other to answer the requested questions and submit video

If you are working in a group, then a video record of collaboration is must otherwise NO grade will be awarded.

Problem: (15 points)

Develop an application to manage the product details using a binary file. Your application should save the information of each field of the product using binary format and each record should be of the same size. Possible operations and sample GUI is provided for your reference.

Design the Main Product GUI that looks like as shown below:

image text in transcribed

File menu has Exit menu item, so when user selects this option, it will terminate the application.

Product menu has two menu items:

Add/Update menu item, so when user selects this option, it will display Add/Update window to the user (shown below).

Find/Display menu item, so when user selects this option, it will display the Find/Display window to the user (shown below).

image text in transcribed

Program the buttons to perform following operations:

Add Should add the information of new product to the file. Product ID should be unique, quantity in hand and unit price should be number and above 0 and name is required. (1 point)

First Should read the first record stored in the file and display the details of it in the controls. (1 point)

Previous if possible, should read the previous record to the current record stored in the file and display the details of it in the controls. (1 point)

Next if possible, should read the next record to the current record stored in the file and display the details of it in the controls. (1 point)

Last Should read the last record stored in the file and display the details of it in the controls. (1 point)

Update should update the information of currently displayed record on the GUI. (1 point)

image text in transcribedimage text in transcribed

image text in transcribed

Program the Find/Display button to perform following operation:

Depending upon which radio button is selected, it should read the product details from the file and display in the JTable/JTextArea.

If All radio button is selected, it should display all the products stored in the file. (1 point)

If Keyword radio button is selected, it should display all the products stored in the file which contains the specified keyword in their name. (1 point)

If Price Range radio button is selected, it should display all the products stored in the file which has the price specified between to and from (1 point)

Evaluation:

Prepare a 5-10 min video demonstrating the execution of each of the requested feature and submit it on the blackboard.

Based upon this video following elements will be graded:

Proper GUI Design (1 point)

FunctionalityData validation and feedback

Unique ID (1 point)

In proper format (1 point)

Requested behavior (9 points)

Prepare another 5-10 min video answering the following given questions. Individual grade will be awarded based upon the answers provided.

How is the new product added to the file? (1 point)

How you made sure the product ID is unique? (1 point)

How retrieved the previousext record of the current record from the file? (1 point)

Explain the updating process of current record. (1 point)

How you extracted the records based upon the keyword in the name of the product? (1 point)

How you retrieved the first and last record from the file? (1 point)

please provide Java code only with GUI

Thanks in Advance

for your Reference I am posting the hangman code with Gui...

import java.awt.*; // package for creating GUI components import java.awt.event.*; // package for handling events import java.io.*; // package for reading/writing files import java.util.*; // package for using ArrayList and HashSet classes import javax.swing.*; // package for creating GUI components

public class hangman extends JFrame implements ActionListener { private JTextField DispWord; // Textfield to display word private JTextField InputGuess;// Textfield to display guess private ArrayList StringWord; // Array(list) of the words for game from text file private JLabel DisplayMissed; // label which displays the number of misses private JButton guessButton; // guess button to make a guess of the letter which is present in the word private String word, displayWord; // the word needs to be guessed and its display pattern private HashSet GuessedLetters; // number of letters that have been tried private int Miss; // number of misses

public hangman() { // Read words from file into words list StringWord = new ArrayList(); try { BufferedReader reader = new BufferedReader(new FileReader("src/hangman/hangman.txt")); String line; while ((line = reader.readLine()) != null) { StringWord.add(line); } reader.close(); } catch (IOException e) { e.printStackTrace(); }

// Select a random word from the list word = StringWord.get((int)(Math.random() * StringWord.size())); //initially displayWord ihas no valuue displayWord = ""; for (int i = 0; i

// Initialize the GUI components Container content = getContentPane(); content.setLayout(new FlowLayout()); DispWord = new JTextField(displayWord, 20); DispWord.setEditable(false); content.add(DispWord); InputGuess = new JTextField(20); content.add(InputGuess); guessButton = new JButton("Guess"); guessButton.addActionListener(this); content.add(guessButton); DisplayMissed = new JLabel("Missed: 0"); content.add(DisplayMissed); GuessedLetters = new HashSet();

setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Hangman"); setSize(300, 200); setVisible(true); }

public void actionPerformed(ActionEvent event) { char guess = Character.toLowerCase(InputGuess.getText().charAt(0)); if (GuessedLetters.contains(guess)) { JOptionPane.showMessageDialog(this, "Try another letter, You tried this letter already.."); InputGuess.setText(""); return; } GuessedLetters.add(guess); boolean correct = false; for (int i = 0; i

public static void main(String[] args) { new hangman(); } }

Problem: (15 points) Develop an application to manage the product details using a binary file. Your application should save the information of each field of the product using binary format and each record should be of the same size. Possible operations and sample GUI is provided for your reference. Design the Main Product GUI that looks like as shown below: - File menu has "Exit" menu item, so when user selects this option, it will terminate the application. - Product menu has two menu items: - "Add/Update" menu item, so when user selects this option, it will display Add/Update window to the user (shown below). - "Find/Display" menu item, so when user selects this option, it will display the Find/Display window to the user (shown below). Program the buttons to perform following operations: - Add - Should add the information of new product to the file. Product ID should be unique, quantity in hand and unit price should be number and above 0 and name is required. ( 1 point) - First - Should read the first record stored in the file and display the details of it in the controls. (1 point) Program the buttons to perform following operations: - Add - Should add the information of new product to the file. Product ID should be unique, quantity in hand and unit price should be number and above 0 and name is required. (1 point) - First - Should read the first record stored in the file and display the details of it in the controls. (1 point) - Previous - if possible, should read the previous record to the current record stored in the file and display the details of it in the controls. ( 1 point) - Next - if possible, should read the next record to the current record stored in the file and display the details of it in the controls. (1 point) - Last - Should read the last record stored in the file and display the details of it in the controls. ( 1 point) - Update - should update the information of currently displayed record on the GUI. (1 point) Program the buttons to perform following operations: - Add - Should add the information of new product to the file. Product ID should be unique, quantity in hand and unit price should be number and above 0 and name is required. (1 point) - First - Should read the first record stored in the file and display the details of it in the controls. (1 point) - Previous - if possible, should read the previous record to the current record stored in the file and display the details of it in the controls. ( 1 point) - Next - if possible, should read the next record to the current record stored in the file and display the details of it in the controls. (1 point) - Last - Should read the last record stored in the file and display the details of it in the controls. ( 1 point) - Update - should update the information of currently displayed record on the GUI. (1 point) Program the Find/Display button to perform following operation: - Depending upon which radio button is selected, it should read the product details from the file and display in the JTable/JTextArea. - If "All" radio button is selected, it should display all the products stored in the file. ( 1 point) - If "Keyword" radio button is selected, it should display all the products stored in the file which contains the specified keyword in their name. (1 point) - If "Price Range" radio button is selected, it should display all the products stored in the file which has the price specified between to and from (1 point)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

=+20.19. Let A ,., () = [IZ, - Z|

Answered: 1 week ago

Question

8 0 8 6 interfacing keypad with 8 2 5 5 assembly code

Answered: 1 week ago