Como poner caracter en color
Publicado por Azu (1 intervención) el 08/05/2003 10:49:11
Hola!
Queria saber como puedo poner en un jTextPane un caracter en un color distinto a los demas que ya haya insertado. Lo he intentado poner asi:
JTextPane text = new JTextPane();
Document doc = text.getDocument();
SimpleAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setBackground(attributeSet,Color.red);
StyleConstants.setForeground(attributeSet,Color.white);
doc.insertString(doc.getLength(),"Una frase",attr);
pero al compilarlo me da un error :"unreported exception...", no se si hay que tratar alguna excepcion y como.
Agradeceria mucho vuestras respuestas.
Queria saber como puedo poner en un jTextPane un caracter en un color distinto a los demas que ya haya insertado. Lo he intentado poner asi:
JTextPane text = new JTextPane();
Document doc = text.getDocument();
SimpleAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setBackground(attributeSet,Color.red);
StyleConstants.setForeground(attributeSet,Color.white);
doc.insertString(doc.getLength(),"Una frase",attr);
pero al compilarlo me da un error :"unreported exception...", no se si hay que tratar alguna excepcion y como.
Agradeceria mucho vuestras respuestas.
Valora esta pregunta


0