Get an object from a class

Im trying to figure out how to get an object for another class, i cant figure it out...is thier a way to do this. Here is an example of what im tying to do

Lets say i have the main class, in that class i create a zoomPanel() object

zoomPanel zP =new zoomPanel();

zP.moveLeft();

in the zoom panel class i have things like

publicvoid moveLeft()

{

}

publicvoid moveRight()

{

}

but in the class i want to get the object i have

class keyPressextends zoomPanelimplements KeyListener

{

publicvoid left()

{

moveLeft();

}

}

when i press the left arrow i need it to move zP left

[1237 byte] By [The_Undeada] at [2007-11-27 11:45:31]
# 1

You design smells a bit but to fix you immediate problem (I think):

super.moveLeft();

floundera at 2007-7-29 18:02:12 > top of Java-index,Java Essentials,New To Java...
# 2

Your keyPress class (should be KeyPress) won't compile. If it is going to implement KeyListener it must implement the KeyListener methods: keyPressed(), keyReleased() and keyTyped(). Within these methods you can call the methods of the base class: moveLeft() and so on.

pbrockway2a at 2007-7-29 18:02:12 > top of Java-index,Java Essentials,New To Java...
# 3

> Your keyPress class (should be KeyPress) won't

> compile. If it is going to implement KeyListener it

> must implement the KeyListener methods: keyPressed(),

> keyReleased() and keyTyped(). Within these methods

> you can call the methods of the base class:

> moveLeft() and so on.

It does, i just took out certain things so it doesnt take up a hole page on the foum, ahh thanksflounder

The_Undeada at 2007-7-29 18:02:12 > top of Java-index,Java Essentials,New To Java...
# 4

Never mind, that doesnt seem to do anything... :(

The_Undeada at 2007-7-29 18:02:12 > top of Java-index,Java Essentials,New To Java...
# 5

I'm not surprised. You have an object of the zoomPanel class but it is your keyPress class that is the KeyListener. Do you expect magic to hapen?

floundera at 2007-7-29 18:02:12 > top of Java-index,Java Essentials,New To Java...