TinyBelly
TinyBelly

Reputation: 3397

Basic question about JLabel

Since i declare:

double total = 12.00;

why i cant put:

p1.add(jlbTotal= new JLabel (total));

Is there any way I can use to insert that total value?

Upvotes: 0

Views: 2235

Answers (1)

Mat
Mat

Reputation: 206747

JLabel does not take doubles in its constructors. You first need to convert your double to a String. For example:

new JLabel(String.valueOf(total));

Upvotes: 5

Related Questions