开发者

Basic question about JLabel

开发者 https://www.devze.com 2023-02-28 03:39 出处:网络
Since i declare: double total = 12.00; why i cant put: p1.add(jlbTotal= new JLabel (total)); Is there 开发者_如何学Pythonany way I can use to insert that total value?JLabel does not take doubles

Since i declare:

double total = 12.00;

why i cant put:

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

Is there 开发者_如何学Pythonany way I can use to insert that total value?


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));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号