Java - Cómo subrayar texto y negrita en Java Swing

 
Vista:
Imágen de perfil de Edgard

Cómo subrayar texto y negrita en Java Swing

Publicado por Edgard (4 intervenciones) el 24/02/2014 17:19:31
Hola a todos, he declarado tres variables en una clase para que me apliquen formato a unos textos:
1
2
3
Font normal = new Font("Arial", Font.PLAIN, 12);
Font negrita = new Font("Arial", Font.BOLD, 14);
Font cursiva = new Font( "Arial",Font.ITALIC,13 );

El problema que tengo es que no puedo crear un nuevo FONT subrayado, este bloque no me funciona:

1
Font subrayado = new Font("Arial", TextAttribute.UNDERLINE_ON, Font.BOLD);


Habrá manera de subrayar texto y darle Negrilla?
Thanks in advance
Saludos.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Cómo subrayar texto y negrita en Java Swing

Publicado por UnoPorAhi (128 intervenciones) el 25/02/2014 09:15:28
1
2
3
4
5
JLabel label = new JLabel("Underlined Label");
Font font = label.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
label.setFont(font.deriveFont(attributes));


Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Edgard

Cómo subrayar texto y negrita en Java Swing

Publicado por Edgard (4 intervenciones) el 25/02/2014 17:31:14
Gracias por tu ayuda.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Cómo subrayar texto y negrita en Java Swing

Publicado por Sergio (1 intervención) el 16/08/2019 19:37:49
Formulario en SWING netbeans para formatear texto

WhatsApp-Image-2019-08-16-at-9.16.07-AM
WhatsApp-Image-2019-08-16-at-9.15.42-AM
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar