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 Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse 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;...

This is only a preview of the solution. Please use the purchase button to see the entire solution


or free if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats