Java Code Examples for javax.swing.text.html.StyleSheet#addRule()
The following examples show how to use
javax.swing.text.html.StyleSheet#addRule() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleResultOverview.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates the main text representation of this result. * * @param text * @return */ private Component makeMainLabel(String text) { JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text); StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet(); css.addRule("body {font-family:Sans;font-size:11pt}"); css.addRule("h3 {margin:0; padding:0}"); css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}"); css.addRule("p {margin-top:0; margin-bottom:1ex; padding:0}"); css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + Tools.getResource("icons/help/circle.png") + ")}"); css.addRule("ul li {padding-bottom: 2px}"); css.addRule("li.outPorts {padding-bottom: 0px}"); css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + Tools.getResource("icons/help/line.png") + ")"); css.addRule("li ul li {padding-bottom:0}"); label.setEditable(false); label.setBackground(Colors.WHITE); JScrollPane pane = new JScrollPane(label); pane.setBackground(Colors.WHITE); pane.setBorder(null); return pane; }
Example 2
Source File: BrokenPlatformCustomizer.java From netbeans with Apache License 2.0 | 6 votes |
private void postInitComponents () { this.jLabel2.setVisible(false); this.platformHome.setVisible(false); final Collection installFolders = platform.getInstallFolderURLs(); if (platform.getInstallFolders().isEmpty() && installFolders.size() > 0) { this.jLabel2.setVisible(true); this.platformHome.setVisible(true); this.platformHome.setForeground(new Color (164,0,0)); this.platformHome.setText (Utilities.toFile(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath()); } HTMLEditorKit htmlkit = new HTMLEditorKit(); StyleSheet css = htmlkit.getStyleSheet(); if (css.getStyleSheets() == null) { StyleSheet css2 = new StyleSheet(); Font f = jLabel2.getFont(); css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N css2.addStyleSheet(css); htmlkit.setStyleSheet(css2); } jTextPane1.setEditorKit(htmlkit); jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject")); }
Example 3
Source File: OperatorDocumentationBrowser.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * This method creates and returns a stylesheet that makes the documentation look as it's * supposed to look. * * @return the stylesheet */ private StyleSheet createStyleSheet(StyleSheet css) { css.addRule("body {font-family: Open Sans; font-size: 10px;}"); css.addRule("p {font-size:10px; font-family: Open Sans; margin-top: 0px; padding-top: 0px;}"); css.addRule("ul li {padding-bottom:1ex; font-family: Open Sans; font-size:10px; list-style-type: circle;}"); css.addRule("h2 {font-size:14px; font-family: Open Sans; margin-bottom: 0px; margin-top: 0px;}"); css.addRule("h4 {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 5px;}"); css.addRule("h5 {color: #3399FF; font-size:11px; font-family: Open Sans;}"); css.addRule("h5 img {margin-right:8px; font-family: Open Sans;}"); css.addRule( ".parametersHeading {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 0px;}"); css.addRule(".parametersTable {cellspacing: 0px; border: 0;}"); css.addRule(".typeIcon {height: 10px; width: 10px;}"); css.addRule("td {vertical-align: top; font-family: Open Sans;}"); css.addRule(".lilIcon {padding: 2px 4px 2px 0px;}"); css.addRule("td {font-size: 10px; font-family: Open Sans;}"); css.addRule(".packageName {color: #777777; font-size:10px; font-family: Open Sans; font-weight: normal;}"); css.addRule(".parameterDetails {color: #777777; font-size:9px; font-family: Open Sans;}"); css.addRule(".parameterDetailsCell{margin-bottom: 4px; padding-bottom: 4px;}"); css.addRule(".tutorialProcessLink {margin-top: 6px; margin-bottom: 5px;}"); css.addRule("hr {border: 0;height: 1px;}"); css.addRule("a {color:" + SwingTools.getColorHexValue(Colors.LINKBUTTON_LOCAL) + "}"); css.addRule("table {align:left;}"); css.addRule(".tags {font-size: 9px; color: #777777;}"); return css; }
Example 4
Source File: HelpForm.java From WePush with MIT License | 6 votes |
/** * 初始化使用帮助tab */ public static void init() { helpForm = getInstance(); try { helpForm.getHelpTextPane().setEditable(false); HTMLEditorKit kit = new HTMLEditorKit(); helpForm.getHelpTextPane().setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("h2{color:#FBC87A;}"); helpForm.getHelpTextPane().setContentType("text/html; charset=utf-8"); helpForm.getHelpTextPane().setPage(MainWindow.class.getResource("/page/help.html")); } catch (IOException e) { e.printStackTrace(); } }
Example 5
Source File: CommonTipsDialog.java From MooTool with MIT License | 5 votes |
public void setHtmlText(String htmlText) { textPane1.setContentType("text/html; charset=utf-8"); HTMLEditorKit kit = new HTMLEditorKit(); textPane1.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("h2{color:#FBC87A;}"); styleSheet.addRule("body{font-family:" + buttonOK.getFont().getName() + ";font-size:" + buttonOK.getFont().getSize() + ";}"); textPane1.setText(htmlText); }
Example 6
Source File: InfoBuilder.java From raccoon4 with Apache License 2.0 | 5 votes |
@Override protected JPanel assemble() { JPanel ret = new JPanel(); ret.setLayout(new BoxLayout(ret, BoxLayout.Y_AXIS)); content = new HyperTextPane("-").withTransparency(); HTMLEditorKit kit = new HTMLEditorKit(); content.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("body {color:#292929; font-family:Helvetica, Arial, sans-serif; margin: 4px;}"); if (listener != null) { content.addHyperlinkListener(listener); } JPanel wrapper = new JPanel(false); wrapper.setLayout(new GridLayout(1, 0, 0, 0)); JLabel lbl = new JLabel(title, new ImageIcon(getClass().getResource( "/icons/famfam/icons/bell.png")), SwingConstants.LEADING); if (color != null) { lbl.setForeground(color); } wrapper.add(lbl); wrapper.setBackground(wrapper.getBackground().darker()); wrapper.setBorder(BorderFactory.createEtchedBorder()); ret.add(wrapper); ret.add(content); return ret; }
Example 7
Source File: KHtmlEdit.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override protected void initStylesForTextPane(final JTextPane textPane, int mainTextSize) { textPane.setContentType("text/html"); final HTMLDocument doc = (HTMLDocument) textPane.getDocument(); final StyleSheet css = doc.getStyleSheet(); /* * Configure standard styles */ css.addRule("body { font-family: Dialog; font-size: " + (mainTextSize + 1) + "pt }"); css.addRule("a { color: blue; font-style: italic }"); css.addRule("._timestamp { color: " + colorToRGB(HEADER_COLOR) + "; font-size: " + (mainTextSize - 1) + "pt; font-style: italic }"); css.addRule("._header { color: " + colorToRGB(HEADER_COLOR) + " }"); /* * Configure notification types */ for (final NotificationType type : NotificationType.values()) { final Color color = type.getColor(); if (color != null) { css.addRule("." + type.getMnemonic() + " { color: " + colorToRGB(color) + "; font-weight: bold; }"); } } }
Example 8
Source File: LongMessageDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a dialog to display a long message. * * @param owner * the owner window in which the dialog is displayed * @param i18nKey * the i18n key * @param message * the actual message * @param i18nArgs * additional i18n arguments * @since 6.5.0 */ public LongMessageDialog(Window owner, String i18nKey, String message, Object... i18nArgs) { super(owner, i18nKey, ModalityType.APPLICATION_MODAL, i18nArgs); JEditorPane textComponent = new ExtendedHTMLJEditorPane("text/html", message); // so it does not steel ENTER from the default button textComponent.setFocusable(false); StyleSheet css = ((HTMLEditorKit) textComponent.getEditorKit()).getStyleSheet(); css.addRule("body { margin : 0; font-family : sans-serif; font-size : 9px; font-style : normal; }"); css.addRule(".error { font-weight:bold; color:red; font-style:plain; }"); css.addRule("code { font-weight:bold; color:#000088; }"); textComponent.setEditable(false); JScrollPane scrollPane = new ExtendedJScrollPane(textComponent); scrollPane.setBorder(createBorder()); layoutDefault(scrollPane, NORMAL, makeCloseButton()); }
Example 9
Source File: MainFrameComponentFactory.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private void setStyleSheets() { StyleSheet styleSheet = new StyleSheet(); styleSheet.addRule("body {font-size: " + Driver.getFontSize() + "pt}"); styleSheet.addRule("H1 {color: red; font-size: 120%; font-weight: bold;}"); styleSheet.addRule("code {font-family: courier; font-size: " + Driver.getFontSize() + "pt}"); styleSheet.addRule(" a:link { color: #0000FF; } "); styleSheet.addRule(" a:visited { color: #800080; } "); styleSheet.addRule(" a:active { color: #FF0000; text-decoration: underline; } "); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); htmlEditorKit.setStyleSheet(styleSheet); mainFrame.summaryHtmlArea.setEditorKit(htmlEditorKit); }
Example 10
Source File: CommonTipsDialog.java From WePush with MIT License | 5 votes |
public void setHtmlText(String htmlText) { textPane1.setContentType("text/html; charset=utf-8"); HTMLEditorKit kit = new HTMLEditorKit(); textPane1.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("h2{color:#FBC87A;}"); styleSheet.addRule("body{font-family:" + buttonOK.getFont().getName() + ";font-size:" + buttonOK.getFont().getSize() + ";}"); textPane1.setText(htmlText); }
Example 11
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private MainPanel() { super(new BorderLayout()); StyleSheet styleSheet = new StyleSheet(); styleSheet.addRule(".str {color:#008800}"); styleSheet.addRule(".kwd {color:#000088}"); styleSheet.addRule(".com {color:#880000}"); styleSheet.addRule(".typ {color:#660066}"); styleSheet.addRule(".lit {color:#006666}"); styleSheet.addRule(".pun {color:#666600}"); styleSheet.addRule(".pln {color:#000000}"); styleSheet.addRule(".tag {color:#000088}"); styleSheet.addRule(".atn {color:#660066}"); styleSheet.addRule(".atv {color:#008800}"); styleSheet.addRule(".dec {color:#660066}"); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); htmlEditorKit.setStyleSheet(styleSheet); editor.setEditorKit(htmlEditorKit); editor.setEditable(false); JButton button = new JButton("open"); button.addActionListener(e -> { JFileChooser fileChooser = new JFileChooser(); int ret = fileChooser.showOpenDialog(getRootPane()); if (ret == JFileChooser.APPROVE_OPTION) { loadFile(fileChooser.getSelectedFile().getAbsolutePath()); } }); Box box = Box.createHorizontalBox(); box.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); box.add(Box.createHorizontalGlue()); box.add(button); add(new JScrollPane(editor)); add(box, BorderLayout.SOUTH); setPreferredSize(new Dimension(320, 240)); }
Example 12
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private MainPanel() { super(new GridLayout(2, 1)); String html = "<html><h2>H2</h2>text<ul><li>list: %s</li></ul></html>"; JEditorPane editor0 = makeEditorPane(); editor0.setText(String.format(html, "Default")); String url = getClass().getResource("bullet.png").toString(); JEditorPane editor1 = makeEditorPane(); HTMLEditorKit htmlEditorKit = (HTMLEditorKit) editor1.getEditorKit(); StyleSheet styleSheet = htmlEditorKit.getStyleSheet(); styleSheet.addRule(String.format("ul{list-style-image:url(%s);margin:0px 20px;}", url)); editor1.setText(String.format(html, "bullet.png")); // styleSheet.addRule("ul{list-style-type:circle;margin:0px 20px;}"); // styleSheet.addRule("ul{list-style-type:disc;margin:0px 20px;}"); // styleSheet.addRule("ul{list-style-type:square;margin:0px 20px;}"); // styleSheet.addRule("ul{list-style-type:decimal;margin:0px 20px;}"); // Pseudo element is not supported in javax.swing.text.html.CSS // styleSheet.addRule("ul{list-style-type:none;margin:0px 20px;}"); // styleSheet.addRule("ul li:before{content: "\u00BB";}"); add(new JScrollPane(editor0)); add(new JScrollPane(editor1)); setPreferredSize(new Dimension(320, 240)); }
Example 13
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private MainPanel() { super(new GridLayout(3, 1)); add(makeUrlPanel("Default", HREF)); // Customize detault html link color in java swing - Stack Overflow // https://stackoverflow.com/questions/26749495/customize-detault-html-link-color-in-java-swing HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("a{color:#FF0000;}"); add(makeUrlPanel("styleSheet.addRule(\"a{color:#FF0000;}\")", HREF)); add(makeUrlPanel("<a style='color:#00FF00'...", String.format("<html><a style='color:#00FF00' href='%s'>%s</a>", MYSITE, MYSITE))); setPreferredSize(new Dimension(320, 240)); }
Example 14
Source File: IMChatConsole.java From SmartIM with Apache License 2.0 | 5 votes |
protected void initHistoryWidget() { HTMLEditorKit kit = new HTMLEditorKit() { @Override public ViewFactory getViewFactory() { return new WrapHTMLFactory(); } }; final StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("body {text-align: left;}"); styleSheet.addRule(".my {font-size: 1 em; font-style: italic; float: left;}"); styleSheet.addRule("div.error {color: red;}"); styleSheet.addRule("img {max-width: 100%; display: block;}"); styleSheet.addRule(".sender {display: inline; float: left;}"); styleSheet.addRule(".content {display: inline-block; white-space: pre-warp; padding-left: 4px;}"); styleSheet.addRule(".br {height: 1px; line-height: 1px; min-height: 1px;}"); RestUtils.loadStyleAsync(styleSheet); HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument(); String initText = String.format("<html><head></head><body>%s</body></html>", imPanel.getWelcome()); historyWidget.setContentType("text/html"); historyWidget.setEditorKit(kit); historyWidget.setDocument(doc); historyWidget.setText(initText); historyWidget.setEditable(false); historyWidget.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { String desc = e.getDescription(); if (!StringUtils.isEmpty(desc)) { hyperlinkActivated(desc); } } } }); }
Example 15
Source File: JBLabel.java From consulo with Apache License 2.0 | 5 votes |
private void updateStyle(@Nonnull JEditorPane pane) { myEditorPane.setFont(getFont()); myEditorPane.setForeground(getForeground()); EditorKit kit = pane.getEditorKit(); if (kit instanceof HTMLEditorKit) { StyleSheet css = ((HTMLEditorKit)kit).getStyleSheet(); css.addRule("body, p {" + "color:#" + ColorUtil.toHex(getForeground()) + ";" + "font-family:" + getFont().getFamily() + ";" + "font-size:" + getFont().getSize() + "pt;" + "white-space:" + (myAllowAutoWrapping ? "normal" : "nowrap") + ";}"); } }
Example 16
Source File: UpdateInfoDialog.java From MooTool with MIT License | 5 votes |
public void setHtmlText(String htmlText) { textPane1.setContentType("text/html; charset=utf-8"); HTMLEditorKit kit = new HTMLEditorKit(); textPane1.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("h2{color:#FBC87A;}"); styleSheet.addRule("body{font-family:" + buttonOK.getFont().getName() + ";font-size:" + buttonOK.getFont().getSize() + ";}"); textPane1.setText(htmlText); textPane1.setCaretPosition(0); }
Example 17
Source File: DetailsPanel.java From netbeans with Apache License 2.0 | 4 votes |
public DetailsPanel() { initComponents2(); HTMLEditorKit htmlkit = new HTMLEditorKitEx(); // override the Swing default CSS to make the HTMLEditorKit use the // same font as the rest of the UI. // XXX the style sheet is shared by all HTMLEditorKits. We must // detect if it has been tweaked by ourselves or someone else // (code completion javadoc popup for example) and avoid doing the // same thing again StyleSheet css = htmlkit.getStyleSheet(); if (css.getStyleSheets() == null) { StyleSheet css2 = new StyleSheet(); Font f = new JList().getFont(); int size = f.getSize(); css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N css2.addStyleSheet(css); htmlkit.setStyleSheet(css2); } setEditorKit(htmlkit); addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent hlevt) { if (EventType.ACTIVATED == hlevt.getEventType()) { if (hlevt.getURL () != null) { Utilities.showURL(hlevt.getURL()); } } } }); setEditable(false); setPreferredSize(new Dimension(300, 80)); RP.post(new Runnable() { @Override public void run() { getAccessibleContext ().setAccessibleName ( NbBundle.getMessage (DetailsPanel.class, "ACN_DetailsPanel")); // NOI18N } }); putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE ); }
Example 18
Source File: ArtARDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public JPanel getComponent(int width, int height) throws IOException { final JPanel container = new JPanel(); container.setSize(width, height); container.setPreferredSize(container.getSize()); final OverlayLayout overlay = new OverlayLayout(container); container.setLayout(overlay); labelField = new JEditorPane(); labelField.setOpaque(false); labelField.setSize(640 - 50, 480 - 50); labelField.setPreferredSize(labelField.getSize()); labelField.setMaximumSize(labelField.getSize()); labelField.setContentType("text/html"); // add a HTMLEditorKit to the editor pane final HTMLEditorKit kit = new HTMLEditorKit(); labelField.setEditorKit(kit); final StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("body {color:#FF00FF; font-family:courier;}"); styleSheet.addRule("h1 {font-size: 60pt}"); styleSheet.addRule("h2 {font-size: 50pt }"); final Document doc = kit.createDefaultDocument(); labelField.setDocument(doc); // final GridBagConstraints gbc = new GridBagConstraints(); // gbc.gridy = 1; // panel.add(labelField, gbc); container.add(labelField); // labelField.setAlignmentX(0.5f); // labelField.setAlignmentY(0.5f); final JPanel panel = super.getComponent(width, height); container.add(panel); vc.getDisplay().addVideoListener(this); isRunning = true; new Thread(this).start(); return container; }
Example 19
Source File: O365ManualAuthenticatorDialog.java From davmail with GNU General Public License v2.0 | 4 votes |
/** * Get credentials. * * @param initUrl Kerberos prompt from callback handler */ public O365ManualAuthenticatorDialog(String initUrl) { setAlwaysOnTop(true); setTitle(BundleMessage.format("UI_O365_MANUAL_PROMPT")); try { setIconImages(DavGatewayTray.getFrameIcons()); } catch (NoSuchMethodError error) { DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_SET_ICON_IMAGE")); } JPanel messagePanel = new JPanel(); messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.X_AXIS)); JLabel imageLabel = new JLabel(); imageLabel.setIcon(UIManager.getIcon("OptionPane.questionIcon")); messagePanel.add(imageLabel); JEditorPane jEditorPane = new JEditorPane(); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); StyleSheet stylesheet = htmlEditorKit.getStyleSheet(); Font font = jEditorPane.getFont(); stylesheet.addRule("body { font-size:small;font-family: " + ((font==null)?"Arial":font.getFamily()) + '}'); jEditorPane.setEditorKit(htmlEditorKit); jEditorPane.setContentType("text/html"); jEditorPane.setText(BundleMessage.format("UI_0365_AUTHENTICATION_PROMPT", initUrl)); jEditorPane.setEditable(false); jEditorPane.setOpaque(false); jEditorPane.addHyperlinkListener(hle -> { if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) { try { DesktopBrowser.browse(hle.getURL().toURI()); } catch (URISyntaxException e) { DavGatewayTray.error(new BundleMessage("LOG_UNABLE_TO_OPEN_LINK"), e); } } }); messagePanel.add(jEditorPane); JPanel credentialPanel = new JPanel(); credentialPanel.setLayout(new BoxLayout(credentialPanel, BoxLayout.X_AXIS)); JLabel promptLabel = new JLabel(BundleMessage.format("UI_0365_AUTHENTICATION_CODE")); promptLabel.setHorizontalAlignment(SwingConstants.RIGHT); promptLabel.setVerticalAlignment(SwingConstants.CENTER); credentialPanel.add(promptLabel); codeField.setMaximumSize(codeField.getPreferredSize()); codeField.addActionListener(evt -> { code = codeField.getText(); setVisible(false); }); credentialPanel.add(codeField); add(messagePanel, BorderLayout.NORTH); add(credentialPanel, BorderLayout.CENTER); add(getButtonPanel(initUrl), BorderLayout.SOUTH); setModal(true); pack(); // center frame setLocation(getToolkit().getScreenSize().width / 2 - getSize().width / 2, getToolkit().getScreenSize().height / 2 - getSize().height / 2); setAlwaysOnTop(true); setVisible(true); }
Example 20
Source File: AboutAction.java From nextreports-designer with Apache License 2.0 | 4 votes |
private JComponent createPanel() { System.setProperty("awt.useSystemAAFontSettings", "on"); final JEditorPane editorPane = new JEditorPane(); HTMLEditorKit kit = new HTMLEditorKit(); editorPane.setEditorKit(kit); editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); editorPane.setFont(new Font("Arial", Font.PLAIN, 12)); editorPane.setPreferredSize(new Dimension(350, 180)); editorPane.setEditable(false); editorPane.setContentType("text/html"); editorPane.setBackground(new Color(234, 241, 248)); // add some styles to the html StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule(".firstCol {margin-left: 25px; }"); styleSheet.addRule(".secondCol {color: blue; }"); Document doc = kit.createDefaultDocument(); editorPane.setDocument(doc); editorPane.setText( "<html>" + "<body>" + "<table border='0px' BGCOLOR=\"#EAF1F8\">" + "<tr><td colspan=2>" + "<img src='" + ImageUtil.getImageURL("logo").toExternalForm() + "'>" + "</td></tr>" + "<tr><td class=\"firstCol\"><b>" + VERSION + "</b></td><td class=\"secondCol\">" + VERSION_NO + "</td></tr>" + "<tr><td class=\"firstCol\"><b>" + BUILD + "</b></td><td class=\"secondCol\">" + ReleaseInfo.getBuildNumber() + " (" + BUILD_DATE + ")" + "</td></tr>" + "<tr><td class=\"firstCol\"><b>" + SITE + "</b></td><td class=\"secondCol\">"+ "<a href=\"" + SITE_VALUE + "\">" + SITE_SMALL_VALUE + "</a></td></tr>" + "<tr><td class=\"firstCol\"><b>" + COPYRIGHT + "</b></td><td class=\"secondCol\">" + DEVELOPER + "</td></tr>" + "</table>" + "</body>" + "</html>" ); // Add Hyperlink listener to process hyperlinks editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) { EventQueue.invokeLater(new Runnable() { public void run() { SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); editorPane.setToolTipText(e.getURL().toExternalForm()); } }); } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) { EventQueue.invokeLater(new Runnable() { public void run() { SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getDefaultCursor()); editorPane.setToolTipText(null); } }); } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { FileUtil.openUrl(e.getURL().toString(), AboutAction.class); } } }); editorPane.addMouseListener(mouseListener); JScrollPane sp = new JScrollPane(editorPane); return sp; }