List of usage examples for javax.swing JEditorPane setContentType
@BeanProperty(bound = false, description = "the type of content") public final void setContentType(String type)
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.GiftCloudDialogs.java
public void showMessage(final String message) throws HeadlessException { final JPanel messagePanel = new JPanel(new GridBagLayout()); final JEditorPane textField = new JEditorPane(); textField.setContentType("text/html"); textField.setText(message);//from ww w . ja va2 s . co m textField.setEditable(false); textField.setBackground(null); textField.setBorder(null); textField.setEditable(false); textField.setForeground(UIManager.getColor("Label.foreground")); textField.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); textField.setFont(UIManager.getFont("Label.font")); textField.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException e1) { // Ignore failure to launch URL } catch (URISyntaxException e1) { // Ignore failure to launch URL } } } } }); messagePanel.add(textField); textField.setAlignmentX(SwingConstants.CENTER); JOptionPane.showMessageDialog(mainFrame.getContainer(), messagePanel, applicationName, JOptionPane.INFORMATION_MESSAGE, icon); }