Reputation: 901
When using JLabel
, is there a way to use HTML and method call together?
For example:
JLabel speedLabel = new JLabel("<html><b>Speed: </b></html>" + plane.getSpeed());
This doesn't work.
It only shows Speed:
and ignores the rest.
Upvotes: 1
Views: 50
Reputation: 121
it is discarding the values after html close tag if you something like this it will work JLabel speedLabel = new JLabel("<html><b>Speed: " + plane.getSpeed() + "</b></html>");
Upvotes: 1
Reputation: 779
Try to change your code to this:
JLabel speedLabel = new JLabel("<html><b>Speed: " + plane.getSpeed() + " </b></html>");
The text, or in your case the airplane speed, that is probably a double, must be in between the <html>
and </html>
tags, to be recognized.
Upvotes: 2