Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, I am providing you with two files (JavaPadMain and JavaPadModel). You will only have to write JavaPadGUI.java . The only file you

In this assignment, I am providing you with two files (JavaPadMain and JavaPadModel). You will only have to write JavaPadGUI.java . The only file you will have to submit is JavaPadGUI.java. We will not be covering graphic interfaces in this class. I am also providing you with power point slides. Every thing that you need to know for this assignment is in the power point slides. Please read the assignment description in the provided docx file attached.

// This program provides a simple notepad-like editor. public class JavaPadMain {public static void main(String[] args) {JavaPadGUI gui = new JavaPadGUI();}}

import java.io.*;import java.util.*; /** Models JavaPad's internal state. */public class JavaPadModel {private String text;private String lastFileName;private int version; /** Constructs a new model. */public JavaPadModel() {

text = "";lastFileName = null;version = 1;} /** Returns text of the file being edited.* @return the text.*/public String getText() {return text;} /** Returns version number of the file being edited.* @return the version.*/public int getVersion() {return version;} public boolean load(String filename) {boolean result = true;try {Scanner in = new Scanner(new File(filename));

String newtext = "";while (in.hasNextLine()) {newtext += in.nextLine() + " ";}text = newtext;}catch (IOException ioe) {result = false;} return result;} public boolean save(String filename) {boolean result = true;try {

PrintStream out = new PrintStream(new File(filename));out.print(text);lastFileName = filename;}

Power Point

This assignment is designed to test your understanding of writing a basic graphical user interface (GUI) in Java. The key concepts are Swing components, event-driven programming with action events, layout management, input/output, and exception handling.

The scenario for this assignment is as follows: Macrosoft's experiment distributing its browser via sewer rats was an abysmal failure due to the company's unwise choice of Randy the RandomRat to carry the CDs. To recover the lost revenue from this marketing disaster, Macrosoft has decided to enter the office product market with a new word processor named JavaPad XP (tm). Because of your solid work on past projects, you have been selected to write the JavaPad graphical user interface.

Unlike your past projects, there are no provided files from other employees; you're flying solo on this one! Macrosoft does ask, however, that you again use JBuilder 6; your project name is JavaPad. Your project's "main" class (the class with the main method that runs the program) should be named RunJavaPad and should go

in the javapad package. You are also requested to put classes related to the graphical user interface into a package named javapad.gui. Beyond this, you may name your classes, methods, etc. as you like, as long as the names are representative and meaningful.

When the JavaPad program runs, your main window should appear and should have the following properties:

The window title should be: Macrosoft JavaPad XP

The window should start in its default position in the top-left corner of the screen, at pixel position (0, 0).

The window should be resizable.

When the window is closed, the program should terminate.

The content pane of the window should contain the following components:

A label of Macrosoft's company slogan: Macrosoft: Resistance is futile. This label lies in the center of the bottom area of the window. It should stay centered as the window resizes.

A text area in the center of the window. The text area should be initialized with 15 rows and 25 columns. The area is initially blank (contains no text). Long lines should wrap around to the next line. The area becomes scrollable, with a visible vertical scroll bar, when its contents become bigger than the area itself. (The screen shot above at right shows an example.) Its contents can be saved, loaded, and cleared as described below.

Three buttons in the top area of the window, centered horizontally, with the following labeling and click actions:

New: clears text in the main text area

Save: writes text that's currently in the main text area into the file hardcode.txt

Load: reads the file hardcode.txt if possible and places its text into the main text area

Quit: prompts to save, then exits the program

The prompt should be a "confirm dialog" option pane with Yes and No options, with title Quit and message Quitting; Save? The prompt should be a modal child of the JavaPad window. If the user chooses Yes, the program should save the text area's text to hardcode.txt and exit; If the user chooses No, the program should simply exit without saving anything.

(Note that the prompt to save only pops up if the user hits Quit, not if the user closes the window in any other way, such as pressing Alt+F4 or hitting the "X" button at the top-right corner of the window.)

Properties of the window, continued:

The window should be sized exactly to fit the preferred size of the components in it, regardless of platform.

As the window resizes, the buttons and slogan label remain centered horizontally. The buttons and label do not change size as the window resizes. The text area expands to fill all available space as the window resizes. The screenshot below is an example:

Your program should not throw exceptions on failed I/O during save and load operations. When an I/O operation causes an exception (for example, when the file to read isn't found), it should be handled by your program by showing a modal "error option" option pane with title I/O Error and message Could not access file hardcode.txt ; the screenshot to the right provides an example.

Your directions ask that you follow good style guidelines as described in your previous projects, such as encapsulation and access, comments, indentation, spacing, and identifier names, and argument checking. For this project, you are asked to comment using the Javadoc commenting style, with a comment

block on each public class and method; description summaries, as well as use of tags @author, @param, and @return, are required where appropriate.

You are cautioned that various aspects of the program, such as constant strings, numbers and names, could change at a later date, so you are advised to make them into static final constants. These constants should be used throughout the program instead of their literal value.

You should also exercise good object-oriented design in your program. Encapsulate state and behavior intelligently into classes, and represent related/reused code intelligently in methods.

The following is a partial list of Java packages and classes may help you in writing this project:

package java.awt

BorderLayout, FlowLayout, Container

package javax.swing

JFrame, JPanel, JButton, JTextArea, JLabel, JOptionPane, JScrollPane

package java.awt.event

ActionEvent, ActionListener

package java.io

InputStream, InputStreamReader, BufferedReader, OutputStream, PrintStream, IOException

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 International Workshops Gdm Benchmarx Mcis Snsmw Diew Udm Tsukuba Japan April 2010 Revised Selected Papers Lncs 6193

Authors: Masatoshi Yoshikawa ,Xiaofeng Meng ,Takayuki Yumoto ,Qiang Ma ,Lifeng Sun ,Chiemi Watanabe

2010th Edition

3642145884, 978-3642145889

More Books

Students also viewed these Databases questions

Question

explain the concept of strategy formulation

Answered: 1 week ago