List of usage examples for javax.swing JTextPane setSelectedTextColor
@BeanProperty(preferred = true, description = "color used to render selected text") public void setSelectedTextColor(Color c)
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane editorPane = new JTextPane(); editorPane.setSelectedTextColor(Color.red); // set content as html // editorPane.setContentType("text/html"); editorPane.setText("<p color='#FF0000'>Cool!</p>"); // added <u></u> to underlone button JButton label = new JButton("button"); label.setAlignmentY(0.85f);/*from w w w .j ava 2 s .c om*/ label.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger() || e.getButton() == MouseEvent.BUTTON1) { JOptionPane.showMessageDialog(null, "Hello!"); } } }); editorPane.insertComponent(label); frame.getContentPane().add(editorPane); frame.pack(); frame.setVisible(true); }