List of usage examples for javax.swing JEditorPane setAlignmentX
@BeanProperty(description = "The preferred horizontal alignment of the component.") public void setAlignmentX(float alignmentX)
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 w w w .j a v a 2 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); }