Illustrate understanding of inheritance by building a GUI with Java. Your program will enable the user to create and view simple animations in ASCII.
Ascii animation is a nearly lost art form, but it involves creating moving images using nothing but the standard ASCII characters.
Your project is to build a simple GUI that enables the user to create and view ASCII animations. Requirements:
• Use a JFrame or JApplet as the primary interface
• Extend whatever Swing elements you need to create the animation
• Use at least one interface to handle events
• Incorporate a custom panel to accept the animations
• Include buttons or a menu interface to allow moving between frames, saving and loading
• User should be able to edit any frame
• User should be able to navigate between frames
• There should be some mechanism for saving and loading animations
• Animations should be stored via a double-linked list
• Use Object serialization to store and retrieve data to the file
• The best example will have NO loops or arrays.
The AsciiAnim class
Notes about the AsciiAnim class
• It already builds the basic functionality and GUI, Do Not change this for the basic version of your program
• I have added all the buttons and event-handler functionality
• I have even added a Swing timer, but you may need to look this up to see how it works
• My code expects an AsciiCanvas object, which of course you will have to build
• Look at my code to get a sense what the AsciiCanvas should be able to do.
The asciiCanvas
You're expected to build the AsciiCanvas class. This class should have the following capabilities:
• be an extension of JTextArea or something similar
• include the animation (as a linked list of some sort)
• display text in a monospace font
• have methods for moving back and forth in the animation
• have methods for saving and loading the animation
• support animations of at least ten frames
• support the animation button given in the AsciiAnim class
Linked List Animation
• Store your animation as double-linked list.
• You'll need some sort of node class (I called my node AFrame.)
• Each instance of the node represents a single frame of animation.
• Do NOT build an array of nodes.
• Each node should have a next and prev attribute, which will contain references to the appropriate nodes.
• Use the null indicator to describe the beginning and end of the list.
• Make your node serializable to simplify saving and loading
• Your AsciiCanvas will only need two specific instances of the node class:
o head points to the top node on the list
o current points to the current node
• You should only need to save and load the head. Other nodes will come along with the head
As much of the animation code as possible should belong to the AsciiCanvas. The main program shouldn't actually be saving files or switching frames. The main program should be sending requests to the canvas to do the actual work when possible. Encapsulate!
Final deliverable is a zip file with your .java source files and a makefile with make, make run and make clean commands.
Blackbelt extension
There are many ways to extend this project. One obvious extension is to add insert and delete functionality, or the ability to manage multiple animations....


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class AsciiAnim extends JFrame implements ActionListener{

AsciiCanvas cnvAnim = new AsciiCanvas();
JButton btnPrev = new JButton("prev");
JButton btnNext = new JButton("next");
JButton btnSave = new JButton("save");
JButton btnLoad = new JButton("load");
JButton btnAnim = new JButton("animate");

JPanel pnlSouth = new JPanel();
Timer timer = new Timer(100, this);

boolean animating = false;

public AsciiAnim(){
    this.setSize(640, 480);
} // end constructor

public void setUpGUI(){
    //like it says, set up GUI
    Container pnlMain = this.getContentPane();
    pnlSouth.setLayout(new FlowLayout());
    pnlMain.add(cnvAnim, BorderLayout.CENTER);
    pnlMain.add(pnlSouth, BorderLayout.SOUTH);


    //add action listeners

} // end setUpGUI

public void actionPerformed(ActionEvent e){
    if (e.getSource() == btnPrev){
    } else if (e.getSource() == btnNext){
    } else if (e.getSource() == btnAnim){
      //change the animation status
      if (timer.isRunning()){
       this.animating = false;
      } else {
       this.animating = true;
      } // end if
    } else if (e.getSource() == btnSave){;
    } else if (e.getSource() == btnLoad){
    } else if (this.animating == true){
    } else {
      System.out.println("action not defined");
    } // end if
} // end actionPerformed

public static void main(String[] args){
    new AsciiAnim();
} // end main

} // end class def

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

class AsciiCanvas extends JTextArea {

    public static final int COL = 70;
    public static final int ROW = 14;

    public static final String FILE_NAME = "database";
    private static final int FONT_POINTS = 15;

    private int frameNum;
    private AFrame head;
    private AFrame current;...

By purchasing this solution you'll be able to access the following files:

50% discount

$36.00 $18.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats