thieumao

JTextPane setContentType("text/html")

Dec 14th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package javaapplication37;
  6.  
  7. import java.util.Set;
  8. import javax.swing.JFrame;
  9. import javax.swing.JTextPane;
  10.  
  11. /**
  12.  *
  13.  * @author leo
  14.  */
  15. public class JavaApplication37 extends JFrame {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         // TODO code application logic here
  22.         JTextPane textPane = new JTextPane(); // creates an empty text pane
  23.         textPane.setContentType("text/html"); // lets Java know it will be HTML                  
  24.         textPane.setText("<u><span style = 'font-size: 20pt'> Big </span ></u>"); // sets its text
  25.         JFrame frame = new JFrame(); // makes a window to put it in
  26.         frame.getContentPane().add(textPane); // adds the text pane to the window
  27.         frame.pack(); // adjusts the window to the right size
  28.         frame.setVisible(true); // makes it show up
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment