Welcome to Dream.In.Code
Become a Java Expert!

Join 149,489 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,306 people online right now. Registration is fast and FREE... Join Now!




Help with a MadLib's Program

 
Reply to this topicStart new topic

Help with a MadLib's Program, Error Message about MadLib's not being an abstract class.

Help Me Learn Java
18 Mar, 2007 - 09:07 AM
Post #1

New D.I.C Head
*

Joined: 17 Dec, 2006
Posts: 6


My Contributions
[font=Arial][b][color=#33CCFF]This is my code...


CODE
import java.awt.*;
import java.awt.event.*;

public class MadLib extends Frame implements WindowListener {
    private TextArea display;
    private MadDialog dialog;
    
    public MadLib() {
        super("MadLib Game");
        display = new TextArea(" ", 7, 60,
            TextArea.SCROLLBARS_VERTICAL_ONLY);
        display.setFont(new Font("Arial", Font.PLAIN, 16));
        display.setEditable(false);
        add(display);
        addWindowListener(this);
        setLocation(100, 150);
        pack();
        
        dialog = new MadDialog(this);
        dialog.addWindowListener(this);
        dialog.setLocation(150, 100);
        dialog.setVisible(true);
        setVisible(true);
    }
    
    public static void main(String[] args) {
        MadLib ml = new MadLib();
    }
    
    private void buildStory() {
        String story = " ";
        String[] segs = {"One fine ", " night, a ", " named ",
         " ", " had a dream. It was the ", " ", " dream since ",
        " dreamt that a ", " ", " ", " and ", " on a ", " ",
        ". In this dream, and old ", " said to him, \"", "\" ", " ",
        " interpreted this as a sign. To ", ", it meant, ", " ", " ",
        " your ", " ", " a ", " when the moon is ", "." };
        
        String[] s = dialog.getStringarray();
        for (int i = 0; i < s.length; i++) {
            story += segs[i] + s[i];
        }
        story += segs[segs.length - 1];
        display.setText(story);
    }
    
    public void windowClosing(WindowEvent e) {
        if (e.getSource() == this) {
            dispose();
            System.exit(0);
        }
        else if (e.getSource() instanceof Dialog) {
            buildStory();
            ((Dialog)e.getSource()).setVisible(false);
        }
    }
    
    //the rest of them must be delcared
    public void windowActivated(WindowEvent e) { }
    public void windowCLosed(WindowEvent e) { }
    public void windowIconified(WindowEvent e) { }
    public void windowDeiconified(WindowEvent e) { }
    public void windowDeactivated(WindowEvent e) { }
    public void windowOpened(WindowEvent e) { }
}




I am using BlueJ and when I compile the code, I get this error message: "MadLib is not abstract and does not override abstract method windowClosed(java.awt.event.WindowEvent) in java.awt.event.WindowListener

Please help me with this. I am not sure how to fix this problem! Thank you!

This post has been edited by Help Me Learn Java: 18 Mar, 2007 - 09:10 AM
User is offlineProfile CardPM
+Quote Post

horace
RE: Help With A MadLib's Program
18 Mar, 2007 - 09:32 AM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 5 times
Dream Kudos: 50
My Contributions
you have missspelt
CODE

    public void windowCLosed(WindowEvent e) { }

it should be
CODE

    public void windowClosed(WindowEvent e) { }

lower case l not L
User is offlineProfile CardPM
+Quote Post

Help Me Learn Java
RE: Help With A MadLib's Program
18 Mar, 2007 - 09:37 AM
Post #3

New D.I.C Head
*

Joined: 17 Dec, 2006
Posts: 6


My Contributions
Well thank you very much!! I fixed it and it worked! I always make stupid mistakes like that...next time I will be more careful! Have a nice day!
User is offlineProfile CardPM
+Quote Post

horace
RE: Help With A MadLib's Program
18 Mar, 2007 - 09:55 AM
Post #4

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 5 times
Dream Kudos: 50
My Contributions
QUOTE(Help Me Learn Java @ 18 Mar, 2007 - 05:37 PM) *

Well thank you very much!! I fixed it and it worked! I always make stupid mistakes like that...next time I will be more careful! Have a nice day!

problems like that are often very difficult to spot - you tend to read what you intended to write rather than what you did write! someone else reading the code sees them straight away!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 05:13PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month