Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Ready to Program IDE - Keyboard Help?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
KeijiAurion




PostPosted: Mon Jan 15, 2007 10:13 am   Post subject: Ready to Program IDE - Keyboard Help?

Hi, I'm basically computer illiterate, and I am stuck on how to make keyboard input move things across a GUI in Java. I'm using the Ready to Program Java IDE compiler, and I've run into a problem.

I'm guessing I have to create whatever I want to move in the paint area (For this example, I'm using a circle). Will I have to somehow classify this circle as an object?

I have found a tutorial on how to read keyboard input and determine the key code, if it is an action key, a modifier, and the location on the keyboard; but I'm unsure of what coding I'll need to modify this to move this circle around.

Oh, by the way, I already know that this program is junk. Please, spare me from any flames like that; if I could use a proper Java compiler, I would.

This is the tutorial I got:

code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Dimension;

public class KeyEventDemo extends JPanel
                          implements KeyListener,
                                     ActionListener {
    JTextArea displayArea;
    JTextField typingArea;
    static final String newline = "\n";

    public KeyEventDemo() {
        super(new BorderLayout());

        JButton button = new JButton("Clear");
        button.addActionListener(this);

        typingArea = new JTextField(20);
        typingArea.addKeyListener(this);

        //Uncomment this if you wish to turn off focus
        //traversal.  The focus subsystem consumes
        //focus traversal keys, such as Tab and Shift Tab.
        //If you uncomment the following line of code, this
        //disables focus traversal and the Tab events will
        //become available to the key event listener.
        //typingArea.setFocusTraversalKeysEnabled(false);

        displayArea = new JTextArea();
        displayArea.setEditable(false);
        JScrollPane scrollPane = new JScrollPane(displayArea);
        scrollPane.setPreferredSize(new Dimension(375, 125));

        add(typingArea, BorderLayout.PAGE_START);
        add(scrollPane, BorderLayout.CENTER);
        add(button, BorderLayout.PAGE_END);
    }

    /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
        displayInfo(e, "KEY TYPED: ");
    }

    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
        displayInfo(e, "KEY PRESSED: ");
    }

    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
        displayInfo(e, "KEY RELEASED: ");
    }

    /** Handle the button click. */
    public void actionPerformed(ActionEvent e) {
        //Clear the text components.
        displayArea.setText("");
        typingArea.setText("");

        //Return the focus to the typing area.
        typingArea.requestFocusInWindow();
    }

    /*
     * We have to jump through some hoops to avoid
     * trying to print non-printing characters
     * such as Shift.  (Not only do they not print,
     * but if you put them in a String, the characters
     * afterward won't show up in the text area.)
     */
    protected void displayInfo(KeyEvent e, String s){
        String keyString, modString, tmpString,
               actionString, locationString;

        //You should only rely on the key char if the event
        //is a key typed event.
        int id = e.getID();
        if (id == KeyEvent.KEY_TYPED) {
            char c = e.getKeyChar();
            keyString = "key character = '" + c + "'";
        } else {
            int keyCode = e.getKeyCode();
            keyString = "key code = " + keyCode
                        + " ("
                        + KeyEvent.getKeyText(keyCode)
                        + ")";
        }

        int modifiers = e.getModifiersEx();
        modString = "modifiers = " + modifiers;
        tmpString = KeyEvent.getModifiersExText(modifiers);
        if (tmpString.length() > 0) {
            modString += " (" + tmpString + ")";
        } else {
            modString += " (no modifiers)";
        }

        actionString = "action key? ";
        if (e.isActionKey()) {
            actionString += "YES";
        } else {
            actionString += "NO";
        }

        locationString = "key location: ";
        int location = e.getKeyLocation();
        if (location == KeyEvent.KEY_LOCATION_STANDARD) {
            locationString += "standard";
        } else if (location == KeyEvent.KEY_LOCATION_LEFT) {
            locationString += "left";
        } else if (location == KeyEvent.KEY_LOCATION_RIGHT) {
            locationString += "right";
        } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) {
            locationString += "numpad";
        } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN)
            locationString += "unknown";
        }

        displayArea.append(s + newline
                           + "    " + keyString + newline
                           + "    " + modString + newline
                           + "    " + actionString + newline
                           + "    " + locationString + newline);
        displayArea.setCaretPosition(displayArea.getDocument().getLength());
    }

    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("KeyEventDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Create and set up the content pane.
        JComponent newContentPane = new KeyEventDemo();
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}


mod edit: wtd added code tags
Sponsor
Sponsor
Sponsor
sponsor
KeijiAurion




PostPosted: Tue Jan 16, 2007 9:51 am   Post subject: Re: Ready to Program IDE - Keyboard Help?

Okay, I've started to try and compile on my own; but it's just not working. *sighs* I think I understand KeyListeners and KeyEvents and such; but I'm getting a lot of events. This is my code:

code:
// Programmed by: John Elasigue
// Date Started: January 10th, 2007
// This is (at least, planned to be) a remake of a Fire Emblem game.
// The "FireEmblem" class.
import java.applet.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class FireEmblem extends Applet
    implements KeyListener,
    ActionListener

{
    Object Player;

    int y = 0;
    int x = 0;
    int turn = 0;

    //Procedure for delays for drawing
    public static void delay (int de)

    {
        try
        {
            Thread.sleep (de);
        }

        catch (Exception e)
        {
            ;
        }
    }


    // This is to be used to handle the arrow keys being typed.
    public void keyTyped (KeyEvent e)
    {
        int id = e.getID ();
        if (id == KeyEvent.KEY_TYPED)
        {
            if (id == 39) // This represents the right arrow being pressed
            {
                Graphics g = g.getGraphics (); //Gets graphics from the paint class
                g.setColor (new Color (0, 100, 0));
                Player = g.fillOval (x, y, 32, 32);
                delay (5);
                g.setColor (new Color (0, 191, 255));
                Player = g.fillOval (x + 32, y, 32, 32); // Moves player's circle to the right.
            }
        }
    }


    public void init ()
    {
        // Place the body of the initialization method here
    } // init method


    public void paint (Graphics g)
    {
        // Draws the green background (the grass)
        g.setColor (new Color (0, 100, 0));
        g.fillRect (0, 0, 320, 320);

        // Draws the grid for movement.
        for (int i = 0 ; i <= 320 ; i = i + 32)
        {
            g.setColor (new Color (0, 0, 0));
            g.drawLine (i, 0, i, 320);
            g.drawLine (0, i, 320, i);
        }

        // Player's circle
        g.setColor (new Color (0, 191, 255));
        Player = g.fillOval (x, y, 32, 32);

        // Enemy circles.
        g.setColor (new Color (255, 64, 64));
        g.fillOval (288, 288, 32, 32);
    } // paint method
} // FireEmblem class


The things in Crimson represent errors I am facing; and here's what is coming up. Unfortunately, I don't understand what the errors are saying to me.

- The abstract method "void actionPerformed(java.awt.event.ActionEvent $1);", inherited from type "java.awt.event.ActionListener", is not implemented in the non-abstract class "Fire Emblem". <--- I'm getting this for the error that's apparently on the first line of code: public class FireEmblem extends Applet

- No method named "getGraphics" was found in type "java.awt.Graphics". <--- I'm getting this error at the area of Graphics g = g.getGraphics ();

- An expression of type "void" is not valid in this context where a value is expected. <--- I'm getting this error when I'm trying to call the Object Player and giving it values; [Player = g.fillOval (x, y, 32, 32);]

I'm thinking that I can't define the Player circle as an object; but I wouldn't know how I could easily discern between the player's circle and the enemy circles. Any help is appreciated!
HellblazerX




PostPosted: Tue Jan 16, 2007 2:07 pm   Post subject: Re: Ready to Program IDE - Keyboard Help?

KeijiAurion wrote:
- The abstract method "void actionPerformed(java.awt.event.ActionEvent $1);", inherited from type "java.awt.event.ActionListener", is not implemented in the non-abstract class "Fire Emblem". <--- I'm getting this for the error that's apparently on the first line of code: public class FireEmblem extends Applet

Your class, FireEmblem, implements the interface ActionListener, so FireEmblem inherits all the methods within ActionListener. Because ActionListener is an interface, all methods within it are abstract, meaning they are not fully implemented. Your class, FireEmblem, is non-abstract, so therefore it cannot have any abstract methods within it. The only way to get rid of these abstract methods is to override them, by declaring your own methods with the same name. In this case, you need a method within your class called "void actionPerformed (ActionEvent e)".

KeijiAurion wrote:
- No method named "getGraphics" was found in type "java.awt.Graphics". <--- I'm getting this error at the area of Graphics g = g.getGraphics ();

This one is pretty obvious. There is no method named getGraphics in your Graphics object "g". Also, you haven't instantiated "g", so you can't call any methods within it. I think what your really looking for is this:
Java:
Graphics g = this.getGraphics () //this refers to your class FireEmblem


KeijiAurion wrote:
- An expression of type "void" is not valid in this context where a value is expected. <--- I'm getting this error when I'm trying to call the Object Player and giving it values; [Player = g.fillOval (x, y, 32, 32);]

The method fillOval does not return any values, hence the "void", so you cannot use that line.

KeijiAurion wrote:
I'm thinking that I can't define the Player circle as an object; but I wouldn't know how I could easily discern between the player's circle and the enemy circles. Any help is appreciated!

What you need to do is to define your own class called Circle that will contain the neccessary values you need.
KeijiAurion




PostPosted: Tue Jan 16, 2007 6:03 pm   Post subject: Re: Ready to Program IDE - Keyboard Help?

HellblazerX @ Tue Jan 16, 2007 2:07 pm wrote:
Your class, FireEmblem, implements the interface ActionListener, so FireEmblem inherits all the methods within ActionListener. Because ActionListener is an interface, all methods within it are abstract, meaning they are not fully implemented. Your class, FireEmblem, is non-abstract, so therefore it cannot have any abstract methods within it. The only way to get rid of these abstract methods is to override them, by declaring your own methods with the same name. In this case, you need a method within your class called "void actionPerformed (ActionEvent e)".


Hrm... I don't quite understand, but am I simply going to make something like this, where I simply leave it empty?:

code:
public void actionPerformed (ActionEvent e)
{
}


HellblazerX @ Tue Jan 16, 2007 2:07 pm wrote:
Java:
Graphics g = this.getGraphics () //this refers to your class FireEmblem


Ah, didn't know it was this.getGraphics (). Thanks for that. I'm pretty sure that's what I'm looking for, too.

HellblazerX @ Tue Jan 16, 2007 2:07 pm wrote:
KeijiAurion wrote:
- An expression of type "void" is not valid in this context where a value is expected. <--- I'm getting this error when I'm trying to call the Object Player and giving it values; [Player = g.fillOval (x, y, 32, 32);]

The method fillOval does not return any values, hence the "void", so you cannot use that line.

KeijiAurion wrote:
I'm thinking that I can't define the Player circle as an object; but I wouldn't know how I could easily discern between the player's circle and the enemy circles. Any help is appreciated!

What you need to do is to define your own class called Circle that will contain the neccessary values you need.


Ah, that makes sense. Is it going to be something like:

code:
Public static PlayerCircle (object o)
{
g.setColor (new Color (0, 191, 255));
Player = g.fillOval (x, y, 32, 32);
}


Or is there something else I put for object o?

Thanks for all your help, too! You're a lifesaver.
HellblazerX




PostPosted: Tue Jan 16, 2007 6:52 pm   Post subject: Re: Ready to Program IDE - Keyboard Help?

KeijiAurion wrote:
code:
public void actionPerformed (ActionEvent e)
{
}

That's fine if you're going to use these methods, but if you're only going to use KeyListeners, then you don't need to implement the ActionListeners. So, in your class declaration line:
Java:
public class FireEmblem extends Applet implements KeyListener, ActionListener

You can omit the last part, ActionListener:
Java:
public class FireEmblem extends Applet implements KeyListener

This way you don't need the "actionPerformed" method.


KeijiAurion wrote:
code:
Public static PlayerCircle (object o)
{
g.setColor (new Color (0, 191, 255));
Player = g.fillOval (x, y, 32, 32);
}

Not quite. I said you should create a new class for your Player circle, like your FireEmblem class, not a method. I sounds like to me you haven't quite gotten a full understanding of object oriented programming, so I'm going to recommend that you check out wtd's tutorial on Java. It's a great tutorial on Java in general, and object oriented programming, which is a must for the type of game you're trying to make.
KeijiAurion




PostPosted: Wed Jan 17, 2007 9:23 am   Post subject: Re: Ready to Program IDE - Keyboard Help?

HellblazerX @ Tue Jan 16, 2007 6:52 pm wrote:
KeijiAurion wrote:
code:
public void actionPerformed (ActionEvent e)
{
}

That's fine if you're going to use these methods, but if you're only going to use KeyListeners, then you don't need to implement the ActionListeners. So, in your class declaration line:
Java:
public class FireEmblem extends Applet implements KeyListener, ActionListener

You can omit the last part, ActionListener:
Java:
public class FireEmblem extends Applet implements KeyListener

This way you don't need the "actionPerformed" method.


I believe I will be, since I'm probably going to try and make some sort of menu screen that will take mouse input. But, I guess, for now, I can omit that since my game is run without any sort of menu screen. Thanks for the tip.

[quote HellblazerX]
KeijiAurion wrote:
code:
Public static PlayerCircle (object o)
{
g.setColor (new Color (0, 191, 255));
Player = g.fillOval (x, y, 32, 32);
}

Not quite. I said you should create a new class for your Player circle, like your FireEmblem class, not a method. I sounds like to me you haven't quite gotten a full understanding of object oriented programming, so I'm going to recommend that you check out wtd's tutorial on Java. It's a great tutorial on Java in general, and object oriented programming, which is a must for the type of game you're trying to make.[/quote][/quote]

Truthfully, I don't have any understanding at all of object oriented programming; I'm severely computer illiterate. Thanks for the link, however. I'll be sure to check that out.

EDIT:

Ugh. I'm stressing, and so confused, and I don't understand this one bit. I've made the following code:

code:
// Programmed by: John Elasigue
// Date Started: January 10th, 2007
// This is (at least, planned to be) a remake of a Fire Emblem game.
// The "FireEmblem" class.
import java.applet.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Graphics;

public class FireEmblem extends Applet
    implements KeyListener
{
    int turn = 0;

    public void init ()
    {
        // Place the body of the initialization method here
    } // init method


    public void paint (Graphics g)
    {
        // Draws the green background (the grass)
        g.setColor (new Color (0, 100, 0));
        g.fillRect (0, 0, 320, 320);

        // Draws the grid for movement.
        for (int i = 0 ; i <= 320 ; i = i + 32)
        {
            g.setColor (new Color (0, 0, 0));
            g.drawLine (i, 0, i, 320);
            g.drawLine (0, i, 320, i);
        }

        // Player's circle
        // g.setColor (new Color (0, 191, 255));
        //Player = g.fillOval (x, y, 32, 32);

        // Enemy circles.
        g.setColor (new Color (255, 64, 64));
        g.fillOval (288, 288, 32, 32);
    } // paint method
} // FireEmblem class

class PlayerCircleMovement extends PlayerCircle
{
    //Procedure for delays for drawing
    public static void delay (int de)

    {
        try
        {
            Thread.sleep (de);
        }

        catch (Exception e)
        {
            ;
        }
    }


    // This is to be used to handle the arrow keys being typed.
    public void keyTyped (KeyEvent e)
    {
        int id = e.getID ();
        if (id == KeyEvent.KEY_TYPED)
        {
            if (id == 39) // This represents the right arrow being pressed
            {
                Graphics g = this.getGraphics (); // Gets graphics from the paint class
                g.setColor (new Color (0, 100, 0));
                Player = g.fillOval (x, y, 32, 32);
                delay (5);
                g.setColor (new Color (0, 191, 255));
                Player = g.fillOval (x + 32, y, 32, 32); // Moves player's circle to the right.
            } // End if - Right Arrow
        } // End if - Key Typing
    } // End keyTyped
}

class PlayerCircle
{
    int y = 0;
    int x = 0;
    protected Object Player;
    public playerPaint (Graphics g)
    {
        // Player's circle
        g.setColor (new Color (0, 191, 255));
        Player = g.fillOval (x, y, 32, 32);
        return Player;
    }
}


But it's just not working. -_- I know something's wrong; but I just can't understand what.

I feel really stupid. Someone, please save me!
wtd




PostPosted: Wed Jan 17, 2007 1:14 pm   Post subject: RE:Ready to Program IDE - Keyboard Help?

There are a great many things wrong with it. Please don't take that as an insult or flame.

Let's look at your simplest class (cleaned up a bit, stylistically):

code:
class PlayerCircle {
    int y = 0;
    int x = 0;
    protected Object Player;

    public playerPaint(Graphics g) {
        // Player's circle
        g.setColor(new Color(0, 191, 255));
        Player = g.fillOval(x, y, 32, 32);
        return Player;
    }
}


Some observations:

PlayerCircle has no constructor.

The playerPaint method has no return type.

The fillOval method that belongs to the Graphics abstract class returns void. You cannot assign that to an Object variable and return it.

The resulting question is:

Why is this method not simply a static one?
KeijiAurion




PostPosted: Thu Jan 18, 2007 7:42 am   Post subject: Re: Ready to Program IDE - Keyboard Help?

I really, really don't know. I don't know what I'm doing anymore, and I think I'm going to abandon this project. I'm running out of time, and it seems like I've gotten nowhere.

*sighs*

Java is so confusing to me, that I'm finding it hard to get a grasp on how to code things. Okay, one last try at understanding this.

On the constructor problem, should it be public class PlayerCircle?

The playerPaint method, should I have (Graphics g, Object o) and then return the object?

Hmm, I still don't really understand between the difference of void and such. Then again, I'm only returning it for the movement section of the code; at least, from what I see...

I don't know why that method isn't static. We were never taught what static meant. We were taught very little; and I think I've tried to tackle a program too big for me.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Jan 18, 2007 2:06 pm   Post subject: RE:Ready to Program IDE - Keyboard Help?

Try reading my Introduction to Java.
KeijiAurion




PostPosted: Thu Jan 18, 2007 7:11 pm   Post subject: Re: Ready to Program IDE - Keyboard Help?

Okay, I rewrote my program (to an extent), and used some of another person's source code; and I'm down to one single error.

code:
// Programmed by: John Elasigue
// Date Started: January 10th, 2007
// This is (at least, planned to be) a remake of a Fire Emblem game.
// The "FireEmblem2" class.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class FireEmblem2 extends JApplet
    implements KeyListener, FocusListener, MouseListener
{

    int PlayerX = 0; // These are beginning coordinates for the
    int PlayerY = 0; // Player's circle

    boolean focussed = false;   // True when this applet has input focus.

    DisplayPanel canvas;  // The drawing surface on which the applet draws,
    // belonging to a nested class DisplayPanel, which
    // is defined below.

    //Procedure for delays for drawing
    public static void delay (int de)

    {
        try
        {
            Thread.sleep (de);
        }

        catch (Exception e)
        {
            ;
        }
    }


    public void init ()
    {
        int turn = 0; // Variable to determine whose turn is currently in play.

        canvas = new DisplayPanel (); // Create drawing surface and
        setContentPane (canvas);      // install it as the applet's content pane.

        canvas.setBackground (new Color (0, 100, 0)); // Set the background color of the canvas.

        canvas.addFocusListener (this);  // Set up the applet to listen for events
        canvas.addKeyListener (this);    // from the canvas.
        canvas.addMouseListener (this);
    } // init method


    class DisplayPanel extends JPanel
    {
        // An object belonging to this nested class is used as
        // the content pane of the applet.  It displays the
        // moving square on a white background with a border
        // that changes color depending on whether this
        // component has the input focus or not.
        public void paintComponent (Graphics g)
        {
            super.paintComponent (g); // Fills the panel with its
            // background color, which is white.

            // Draws the green background (the grass)
            g.setColor (new Color (0, 100, 0));
            g.fillRect (0, 0, 320, 320);

            // Draws the grid for movement.
            for (int i = 0 ; i <= 320 ; i = i + 32)
            {
                g.setColor (new Color (0, 0, 0));
                g.drawLine (i, 0, i, 320);
                g.drawLine (0, i, 320, i);
            }

            // Player's circle
            g.setColor (new Color (0, 191, 255));
            g.fillOval (PlayerX, PlayerY, 32, 32);

            // Enemy circles.
            g.setColor (new Color (255, 64, 64));
            g.fillOval (288, 288, 32, 32);
        } // End PaintComponent Method
    } // End Nested Class DisplayPanel


    // ------------------- Event handling methods ----------------------

    public void focusGained (FocusEvent evt)
    {
        // The applet now has the input focus.
        focussed = true;
    }


    public void focusLost (FocusEvent evt)
    {
        // The applet has now lost the input focus.
        focussed = false;
    }


    public void keyPressed (KeyEvent evt)
    {
        // Called when the user has pressed a key, which can be
        // a special key such as an arrow key.  If the key pressed
        // was one of the arrow keys, move the square (but make sure
        // that it doesn't move off the edge, allowing for a
        // 3-pixel border all around the applet).

        int key = evt.getKeyCode (); // keyboard code for the key that was pressed

        if (key == KeyEvent.VK_LEFT)
        {
            /*squareLeft -= 8;
            if (squareLeft < 3)
                squareLeft = 3;
            canvas.repaint ();*/
        }
        else if (key == KeyEvent.VK_RIGHT)
        {
            PlayerX += 32;
            delay (5);
            canvas.repaint ();
            /*squareLeft += 8;
            if (squareLeft > getSize ().width - 3 - SQUARE_SIZE)
                squareLeft = getSize ().width - 3 - SQUARE_SIZE;
            canvas.repaint ();*/
        }
        else if (key == KeyEvent.VK_UP)
        {
            /*squareTop -= 8;
            if (squareTop < 3)
                squareTop = 3;
            canvas.repaint ();*/
        }
        else if (key == KeyEvent.VK_DOWN)
        {
            /*squareTop += 8;
            if (squareTop > getSize ().height - 3 - SQUARE_SIZE)
               squareTop = getSize ().height - 3 - SQUARE_SIZE;
            canvas.repaint ();*/
        }

    } // end keyPressed()


    public void keyReleased (KeyEvent evt)
    {
        // empty method, required by the KeyListener Interface
    }


    public void mousePressed (MouseEvent evt)
    {
        // Request that the input focus be given to the
        // canvas when the user clicks on the applet.
        canvas.requestFocus ();
    }


    public void mouseEntered (MouseEvent evt)
    {
    } // Required by the


    public void mouseExited (MouseEvent evt)
    {
    } //    MouseListener


    public void mouseReleased (MouseEvent evt)
    {
    } //       interface.


    public void mouseClicked (MouseEvent evt)
    {
    }


    /* This is to be used to handle the arrow keys being typed.
    public void PlayerCircleMovement (KeyEvent e, Graphics g)
    {
        int id = e.getID (); // gets the ID Of the key pressed
        if (id == KeyEvent.VK_RIGHT) // Checks to see if the Key was simply pressed.
        {
            g.setColor (new Color (0, 100, 0));
            g.fillOval (x, y, 32, 32);
            delay (5);
            g.setColor (new Color (0, 191, 255));
            g.fillOval (x + 32, y, 32, 32); // Moves player's circle to the right.
        } // End if - Key Typing
    } // End keyTyped */
} // FireEmblem class


My only problem is in the line: public class FireEmblem2 extends JApplet

It says my problem is: The abstract method "void keyTyped(java.awt.event.KeyEvent $1);", inherited from type "java.awt.event.KeyListener", is not implemented in the non-abstract class "FireEmblem2".

What does it mean by abstract and non-abstract class? T_T..
KeijiAurion




PostPosted: Fri Jan 19, 2007 5:32 pm   Post subject: Re: Ready to Program IDE - Keyboard Help?

*blushes* Ahh... I found out the problem. I had forgotten a keyTyped class, which is apparently required by all KeyListeners. Haha. I feel stupid.

Thanks for all the help, though. I really appreciate it, guys. You've helped me learn a lot about Java!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: