Hello everyone. I've been trying to make the font of a JLabel underlined. I found this solution:
Map map = myView.getMyJLabel().getFont().getAttributes();
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
myView.getMyJLabel().setFont(new Font(map));
However, I can't make this 2 warnings dissapear:
Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized.
Type safety: The expression of type Map needs unchecked conversion to conform to Map<? extends AttributedCharacterIterator.Attribute, ?>
I've also tried this:
Map<TextAttribute, ?> map = myView.getMyJLabel().getFont().getAttributes();
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
myView.getMyJLabel().setFont(new Font(map));
But in this case I get the following error:
The method put(TextAttribute, capture-of ?) in the type Map<TextAttribute, capture-of ?> is not applicable for the arguments (TextAttribute, Integer)
Does anyone know how can I get rid of this warnings or maybe, a simpler way to underline a JLabel's text?
Thanks in advance :)