im a newbie and im learning java just week ago. I wonder how i cant make the ball bounce in one axis only (the X axis)
im not good in logic:( and i want that logic to be in one event.

if(x<0){
++x;//go right
}else if(x>500)
{--x;//go left
}

In English:
if x is less than zero go right one step
if x is greater than 500 go left one step therefore
if x is between 0 and 500 do nothing
... but it should continue to move in whatever its current direction is.

Think about keeping track of its current direction, moving that way while the ball is in range, and changing the direction when the ball reaches 0 or 500.

If in doubt, write it down in English and run through a few cases on a piece of paper to get the algorithm right before you try to code it in Java.

yeah i used to write down the codes in paper before in pc. Im thinking to create a method to go right and method to go left but i want it to be in one event :| im nearly giving up with this.

Hint.
When people animate things moving around the screen they usually have variables to hold the h & v velocity of the object (that's the amount by which the x and y positions change in each time cycle). So every time cycle its just xPosition = xPosition + xVelocity; (ditto for y)
if xVelocity is (say) +1 the object will move slowly right. If it's -10 the object will move rapidly left.
Does that help?

What do you mean by "one event"? Your terms are unusual.

Hi Norm
I guess (I really really hope) he is using a javax.swing.Timer to control this. Swing Timers generate an event every n mSec, which passes an ActionEvent object to your code. So "event" would be the appropriate term in this case.
J

Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...