Results 1 to 6 of 6

Thread: Java help

  1. #1

    Java help

    Ok well in my java class I have no clue what I'm doing with this new assignment we have. So I am just guessing at everything. Can someone help me with this program? Here are the
    instructions.

    And here is the code I have so far:

    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;

    public class MoveIt extends Frame implements ActionListener
    {
    private Image cup;
    private Panel keyPad;
    public int top = 10;
    public int left = 10;
    private Button keysArray[];

    public void init()
    {
    cup = getImage( get DocumentBase(), "cup.gif");
    Canvas myCanvas = new Canvas();

    public MoveIt()
    {
    lcd = new TextField(20);
    lcd.setEditable(false);
    keypad = new Panel();
    keys = new Button[5];

    for (int i=0; i<=5; i++)
    keys[i] = new Button(String.valueOf(i));

    keys[1] = new Button("Up");
    keys[2] = new Button("Left");
    keys[3] = new Button("Right");
    keys[4] = new Button("Down");
    keys[5] = new Button("Center");

    setBackground(Color.blue);
    setLayout(new BorderLayout());

    add(myCanvas, BorderLayout, NORTH);
    add(keypad, BorderLayout, SOUTH);

    Up.addActionListener(this);
    Left.addActionListener(this);
    Right.addActionListener(this);
    Down.addActionListener(this);
    Center.addActionListener(this);

    Up.setActionCommand("Up");
    Left.setActionCommand("Left");
    Right.setActionCommand("Right");
    Down.setActionCommand("Down");
    Center.setActionCommand("Center");

    public void actionPerformed(ActionEvent e)
    {
    String arg = e.getActionCommand();

    if (arg == "Up")
    {


    public void paint( Graphics g)
    {
    g.drawImage( cup, left, top, this);
    }

  2. #2
    Join Date
    Apr 2004
    Posts
    52
    You aren't ending any of your functions, you also aren't ending the class. In short, every open curly brace { needs to have a corresponding closing curly brace }. A short example

    Code:
    public class MoveIt extends Frame implements ActionListener
    {
        public void init()
       {
       cup = getImage( get DocumentBase(), "cup.gif");
       Canvas myCanvas = new Canvas();
       }
    }

    I didn't look at all the code, and that is all I'm willing to say since this if for a class. Asking for help with parts of it or explanations would be fine, but this is pretty much cheating in *my* book. To not be able to formulate specific questions shows me that you really should be speaking to your professor about your fundamental understanding of the material.

    If you want the answer, ask your professor. If he/she won't give it to you, then obviously asking on a forum isn't right.

  3. #3
    I know about ending my brackets and I don't care about if im cheating or not cause I can never get help and I read my chapters over and over and they don't explain clearly. People in my class always have to come for me to help them with their programs, but with this program I just don't understand some of it. Plus I'm not asking for someone to do the program for me, but to help me.>.< I can't learn if someone does it for me... And if it makes you happier I have no clue on what to do on #14, 16, and 17. Examples would be nice cause I don't mind doing this for myself for this is my assignment. And if my teacher doesn't give me the answer or help me then how isn't it right for me to ask it on a forum?
    Last edited by markerpower; 05-04-2004 at 11:21 PM.

  4. #4
    Originally posted by markerpower
    I know about ending my brackets and I don't care about if im cheating or not cause I can never get help and I read my chapters over and over and they don't explain clearly. People in my class always have to come for me to help them with their programs, but with this program I just don't understand some of it. Plus I'm not asking for someone to do the program for me, but to help me.>.< I can't learn if someone does it for me... And if it makes you happier I have no clue on what to do on #14, 16, and 17. Examples would be nice cause I don't mind doing this for myself for this is my assignment. And if my teacher doesn't give me the answer or help me then how isn't it right for me to ask it on a forum?
    http://www.google.com

    or more specifically:

    http://www.google.com/search?hl=en&i...=Google+Search

    Take your pick of ~752,000 results

    you're sure to come across something that explains it in language you understand.

  5. #5
    Thanks, but search engines don't work on my computer barely any page does anymore. I have an unstable internet connection...

  6. #6
    Originally posted by markerpower
    Thanks, but search engines don't work on my computer barely any page does anymore. I have an unstable internet connection...
    Wow!.. and to think THESE forums use about 3x the bandwidth and data transfer as a simple text-based search engine..


    Hmmm.. now why does that not make very much sense???

    Hmmm... /me looks around.. "can anybody help this poor confused coder understand how he can be posting here on forums, when google search uses less data transfer???"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •