I'm creating this in java 4 buttons and output area
When the user click button 1 it will show in the output the following

564(0, 0)            //  564 is id number and 0 is location in the x axis and 0 is in the y axis 
564(2, 6)     //using v.move the location in the x and y axis will change to 2,6  

When the user click button 2 it will show in the output the following

125(7, 3)

How can I move 564(0, 0) one unit to the right and report its location also repeat 20 times and report location after each move ( all I know is that I need for loop )

Can you post a small complete program that compiles, executes and shows what you want?

public class program {

    private String id;  
    private int x;     
    private int y;     



    public object (String id, int x, int y) {
        this.id = id;
        this.x = x;
        this.y = y;
    }

    public void move(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public String format() {
        String res = "";

        res = id; 
        res = res +"( ";
        res = res + getX();
        res = res + ", ";
        res = res + getY();
        res = res + " )";

        return res;
    }


    public String getId() {
        return id;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
}





//and this is the code for the first two buttons 

       private void BPartAActionPerformed(java.awt.event.ActionEvent evt) {
            v = new Vehicle("AB587 ", 0, 0);
            textOutputArea.append(v.format() + "\n");
            v.move(2, 6);
            textOutputArea.append(v.format() + "\n");


        }

    private void BPartBActionPerformed(java.awt.event.ActionEvent evt) {
        v2 = new Vehicle("F5687", 7, 3);
        textOutputArea.append(v2.format() + "\n");
        int temp1 = v.getX();
        int temp2 = v.getY();
        v2.move(temp1 , temp2);
        textOutputArea.append(v2.format() + "\n");
        v.move(5, 8);
        textOutputArea.append(v.format() + "\n");
        v2.move(2, 4);
         textOutputArea.append(v2.format() + "\n");

The end of the posted code is missing.

I don't think that there is code messing ..
this is every thing I wrote the first two button work

The method name move() looks like it should be called setLocation() instead... To move, it should indicate the number of step moving to x axis and y axis, not assign the value to x and y... If you want it to really call move(), you need to add the incoming values to their proper variables instead...

I don't think that there is code messing ..

There must be. All programs end with one or more }s
The code you posted does not have any }s at the end of the code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.