How to Return the statement of an attribute on a Jlabel?

Asked

Viewed 64 times

0

I am beginner in programming, my question is the following:
- I created an attribute public static final double Preco_Gasolina = 3.85, in an A class.
- I want to return the value of Preco_Gasolina = 3.85 in a JLabel in Class B.

That’s possible, as I do?

1 answer

2


In class B, just do so:

myJLabel.setText(String.valueOf(A.Preco_Gasolina));

As its attribute is static and public, just reference the class A and call it directly, making the conversion of double for String, using valueOf().

  • Friend your tip worked. But appears an incompatibility to convert from Double to String.

  • @Eliveltonfrance sorry I fixed already. If you find another problem just talk :)

  • Good! Problem solved. Obg!

  • @Eliveltonfrança that good! : ) if the answer answered you, you can mark as accepted by clicking on v, thus, it will serve as reference for others with the same problem;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.