Hola.. bueno estaba aburrido y bueno y quise hacer una aplicación en Java que te convierte el texto a negrita,cursiva y a plana
bueno aquí el código
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public clase21(){
super ("Fontenizar");
this.definirVentana();
this.setSize(400,400);
this.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE); this.setVisible(true);
}
private void definirVentana() {
add(texto);
add(negrita);
add(cursiva);
negrita.addItemListener(this);
cursiva.addItemListener(this);
}
if(negrita.isSelected() && cursiva.isSelected()){
//cambie el texto a negrita y cursiva
fuente
= new Font("Serief",
Font.
BOLD|Font.
ITALIC,
14); texto.setFont(fuente);
}else if (cursiva.isSelected()){
//Cambie el texto a cursiva
fuente
= new Font("Serief",
Font.
ITALIC,
14); texto.setFont(fuente);
}else if (negrita.isSelected()){
fuente
= new Font("Serief",
Font.
BOLD,
14); texto.setFont(fuente);
}else{
fuente
= new Font("Serief",
Font.
PLAIN,
14); texto.setFont(fuente);
}
}
}
Gracias.
Estaría genial que tu aplicación también se pueda seleccionar el tipo de letra.
Saludos.