How to call the value of a variable?

3

How can I call the value of a variable of a function, into another function?

I'm using jPanel , where I'm going to add text with:

 jTextArea.append("AREA = " + /*AQUI*/);

Where it says HERE I wanted to put the value of a variable that I have in another class:

 public int setCoordenadasB(int x1, int y1, int x2, int y2) {
    p.x = Math.min(x1, x2);
    p.y = Math.min(y1, y2);
    largura = Math.abs(x1-x2);
    altura = Math.abs(y1-y2);
    area = largura * altura;
    return area;
}

It was this "area" that I liked to put in HERE up there.

The setCoordenadasB method is in class called rectangle and jTextArea is in the main function, and the rectangle object was started as:

r = new Retangulo();
    
asked by anonymous 27.12.2015 / 19:45

1 answer

2

It would be a simple method call, assuming you already have the 2 coordinates in 4 variables of the same name within the main() method:

jTextArea.append("AREA = " + r.setCoordenadasB(x1, y1, x2, y2));
    
27.12.2015 / 19:52