use of javax.swing.JEditorPane in project jgnash by ccavanaugh.
the class NewFileTwo method initComponents.
private void initComponents() {
helpPane = new JEditorPane();
helpPane.setEditable(false);
helpPane.setEditorKit(new StyledEditorKit());
helpPane.setBackground(getBackground());
helpPane.setText(TextResource.getString("NewFileTwo.txt"));
}
use of javax.swing.JEditorPane in project jabref by JabRef.
the class EntryEditorTabRelatedArticles method setHtmlText.
/**
* Takes a List of HTML snippets stored in the field "html_representation" of a list of bibentries and sets it in the JEditorPane
*
* @param list of bib entries having a field html_representation
*/
public void setHtmlText(List<BibEntry> list) {
StringBuilder htmlContent = new StringBuilder();
URL url = IconTheme.getIconUrl("mdlListIcon");
htmlContent.append("<html><head><title></title></head><body bgcolor='#ffffff'>");
htmlContent.append("<ul style='list-style-image:(");
htmlContent.append(url);
htmlContent.append(")'>");
list.stream().map(bibEntry -> bibEntry.getField("html_representation")).filter(Optional::isPresent).map(o -> "<li style='margin: 5px'>" + o.get() + "</li>").forEach(html -> htmlContent.append(html));
htmlContent.append("</ul>");
htmlContent.append("<br><div style='margin-left: 5px'>");
htmlContent.append("<a href='http://mr-dlib.org/information-for-users/information-about-mr-dlib-for-jabref-users/#'>");
htmlContent.append(Localization.lang("What_is_Mr._DLib?"));
htmlContent.append("</a></div>");
htmlContent.append("</body></html>");
this.setText(htmlContent.toString());
}
use of javax.swing.JEditorPane in project tika by apache.
the class TikaGUI method hyperlinkUpdate.
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED) {
try {
URL url = e.getURL();
try (InputStream stream = url.openStream()) {
JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8));
editor.setEditable(false);
editor.setBackground(Color.WHITE);
editor.setCaretPosition(0);
editor.setPreferredSize(new Dimension(600, 400));
String name = url.toString();
name = name.substring(name.lastIndexOf('/') + 1);
JDialog dialog = new JDialog(this, "Apache Tika: " + name);
dialog.add(new JScrollPane(editor));
dialog.pack();
dialog.setVisible(true);
}
} catch (IOException exception) {
exception.printStackTrace();
}
}
}
use of javax.swing.JEditorPane in project tika by apache.
the class TikaGUI method addWelcomeCard.
private void addWelcomeCard(JPanel panel, String name) {
try {
JEditorPane editor = new JEditorPane(TikaGUI.class.getResource("welcome.html"));
editor.setContentType("text/html");
editor.setEditable(false);
editor.setBackground(Color.WHITE);
editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this));
panel.add(new JScrollPane(editor), name);
} catch (IOException e) {
e.printStackTrace();
}
}
use of javax.swing.JEditorPane in project processdash by dtuma.
the class AutoUpdateManager method displayUpdateMessage.
/** Display a message box, telling the user that various packages are
* now available for download.
*/
protected void displayUpdateMessage(Component parent, int numUpdatesFound) {
HashSet urlsSeen = new HashSet();
DashPackage pkg;
StringBuffer html = new StringBuffer();
html.append("<html><head><style>" + "UL { margin-top: 0pt; margin-bottom: 0pt }" + "</style></head><body>");
for (int i = 0; i < packages.size(); i++) {
pkg = (DashPackage) packages.get(i);
if (!pkg.updateAvailable)
continue;
String userURL = pkg.userURL;
if (userURL == null || urlsSeen.contains(userURL))
continue;
urlsSeen.add(userURL);
ArrayList updates = new ArrayList();
updates.add(pkg.name);
for (int j = i + 1; j < packages.size(); j++) {
pkg = (DashPackage) packages.get(j);
if (pkg.updateAvailable && userURL.equals(pkg.userURL))
updates.add(pkg.name);
}
Collections.sort(updates, String.CASE_INSENSITIVE_ORDER);
html.append("<p>");
String hyperlink = "<a href=\"" + userURL + "\">" + HTMLUtils.escapeEntities(userURL) + "</a>";
html.append(resources.format("Updates_Available_Message_FMT", hyperlink, new Integer(updates.size())));
html.append("<ul>");
Iterator u = updates.iterator();
while (u.hasNext()) {
String updateName = Translator.translate((String) u.next());
html.append("<li>").append(HTMLUtils.escapeEntities(updateName));
}
html.append("</ul>");
}
JEditorPane message = new JEditorPane();
message.setContentType("text/html");
message.setEditable(false);
message.setBackground(null);
message.setText(html.toString());
message.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
Browser.launch(e.getURL().toString());
}
});
JCheckBox disable = new JCheckBox(resources.getString("Do_Not_Check_Label"));
Object[] messageDisplay = new Object[2];
messageDisplay[0] = message;
messageDisplay[1] = disable;
String[] updateOptions = { resources.getString("Remind_Label"), resources.getString("Close_Label") };
int choice = JOptionPane.showOptionDialog(parent, messageDisplay, resources.getString("Updates_Available_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, updateOptions, updateOptions[0]);
if (choice == 0)
InternalSettings.set(AUTO_UPDATE_SETTING + REMIND, "true");
if (disable.isSelected())
InternalSettings.set(AUTO_UPDATE_SETTING + DISABLED, "true");
}
Aggregations