Search results for 'Swing Component Basics'
-
How to add colored text to the document JAVA
By eadoking on August 18, 2009 | 3 Comments
This code generate a colored text in JTextPane like this image import javax.swing.*; import javax.swing.text.*; import java.awt.Color; public class ColorPane extends JTextPane { public void appendNaive(Color c, String s) { // naive implementation // bad: instiantiates a new AttributeSet object on each call SimpleAttributeSet aset = new SimpleAttributeSet(); StyleConstants.setForeground(aset, c); int len = getText().length(); setCaretPosition(len); // place caret at the … ...
Search engine optimization by SEO Design Solutions

Twitter
Facebook
RSS

