Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/10/2014, 06:44
Kritik
(Desactivado)
 
Fecha de Ingreso: marzo-2012
Mensajes: 366
Antigüedad: 12 años, 1 mes
Puntos: 31
JLabel con 2 lineas con fuente externa

Estoy intentando poner 2 líneas en una misma label, he probado con código HTML:

Código:
JLabel lblProxPieza = new JLabel("<html><body><center>"+"Próxima"+"<br>"+"Pieza:"+"<center></body></html>")
y si, me pone 2 líneas... pero luego me deja de funcionar mi fuente externa.

Código:
lblProxPieza.setFont(miFuente.MyFont(0, 18f));

Datos:
el objeto miFuente es un objeto de la siguiente clase:
Código:
public class LedDigital7 {
private Font font;

public LedDigital7() {
    try {
        //Se carga la fuente
        InputStream is =  getClass().getResourceAsStream("LedDigital7.ttf");
        font = Font.createFont(Font.TRUETYPE_FONT, is);
    } catch (Exception ex) {
        //Si existe un error se carga fuente por defecto ARIAL
        System.err.println("Led_digital_7.ttf" + " No se cargo la fuente");
        font = new Font("Arial", Font.PLAIN, 14);            
    }
}

public Font MyFont( int estilo, float tamanio)
{
    return font.deriveFont(estilo, tamanio);
}