use of javax.swing.JEditorPane in project processdash by dtuma.
the class BlameHistoryDialog method showCalculationError.
public void showCalculationError(Throwable calcError) {
calcError.printStackTrace();
ProjectHistoryException phe;
if (calcError instanceof ProjectHistoryException) {
phe = (ProjectHistoryException) calcError;
} else if (projectHistory != null) {
phe = projectHistory.wrapException(calcError);
} else {
phe = new ProjectHistoryException(calcError, "Dir.Cannot_Read_HTML_FMT", dataLocation);
}
String title = resources.getString("Message.Error");
String message = "<html><div style='width:400px'>" + phe.getHtml() + "</div></html>";
JEditorPane pane = new JEditorPane("text/html", message);
pane.setEditable(false);
pane.setBackground(null);
JOptionPane.showMessageDialog(this, pane, title, JOptionPane.ERROR_MESSAGE);
showReadyMessage();
}
use of javax.swing.JEditorPane in project jgnash by ccavanaugh.
the class AboutDialog method addHTMLTab.
private JComponent addHTMLTab(final String name, final String url) {
try {
URL noticeURL = HTMLResource.getURL(url);
JEditorPane p = new JEditorPane(noticeURL);
Font font = UIManager.getFont("Label.font");
String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }";
((HTMLDocument) p.getDocument()).getStyleSheet().addRule(bodyRule);
p.setEditable(false);
p.setAutoscrolls(true);
JScrollPane pane = new JScrollPane(p);
tabbedPane.add(name, pane);
return pane;
} catch (final Exception e) {
Logger.getLogger(AboutDialog.class.getName()).log(Level.SEVERE, e.toString(), e);
}
return null;
}
use of javax.swing.JEditorPane in project Spark by igniterealtime.
the class SparkRes method main.
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
JEditorPane pane = new JEditorPane();
frame.getContentPane().add(new JScrollPane(pane));
StringBuilder buf = new StringBuilder();
Enumeration<String> enumeration = (Enumeration<String>) prb.propertyNames();
while (enumeration.hasMoreElements()) {
String token = enumeration.nextElement();
String value = prb.getProperty(token).toLowerCase();
if (value.endsWith(".gif") || value.endsWith(".png") || value.endsWith(".jpg") || value.endsWith("jpeg")) {
SparkRes.getImageIcon(token);
}
String str = "public static final String " + token + " = \"" + token + "\";\n";
buf.append(str);
}
checkImageDir();
pane.setText(buf.toString());
frame.pack();
frame.setVisible(true);
}
use of javax.swing.JEditorPane in project Spark by igniterealtime.
the class ChatPrinter method setDocument.
/**
* Method to set a PlainDocument as the Document to print.
*
* @param plainDocument the PlainDocument to use.
*/
public void setDocument(PlainDocument plainDocument) {
JEditorPane = new JEditorPane();
setDocument("text/plain", plainDocument);
}
use of javax.swing.JEditorPane in project freeplane by freeplane.
the class SurveyRunner method runServey.
public void runServey(String id, String title, String question, String surveyUrl) {
if (!freeplaneSurveyProperties.mayAskUserToFillSurvey(surveyId))
return;
this.surveyId = id;
freeplaneSurveyProperties.setNextSurveyDay(MINIMAL_DAYS_BETWEEN_SURVEYS);
final JButton go = new JButton("With pleasure");
go.setToolTipText("Thank you so much!");
final JButton notInterested = new JButton("Not interested");
notInterested.setToolTipText("We shall not repeat this question, but may be ask you another one.");
final JButton remindMeLater = new JButton("Remind me later");
remindMeLater.setToolTipText("The same question can be repeated some days later.");
final JButton never = new JButton("Don't ask me anything again");
never.setToolTipText("We are sorry! We shall never ask you any question like this again.");
final JButton[] options = new JButton[] { go, notInterested, remindMeLater, never };
final OptionButtonListener optionButtonListener = new OptionButtonListener();
for (JButton button : options) button.addActionListener(optionButtonListener);
final List<Image> iconImages = UITools.getFrame().getIconImages();
final JEditorPane messageComponent = new JEditorPane("text/html", question);
messageComponent.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(10, 10, 10, 10)));
messageComponent.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
final URL url = e.getURL();
openSurvey(url);
} catch (Exception ex) {
}
userVisitedVotingLink = true;
SwingUtilities.getWindowAncestor(messageComponent).setVisible(false);
}
}
});
messageComponent.setEditable(false);
messageComponent.addHierarchyListener(new HierarchyListener() {
@Override
public void hierarchyChanged(HierarchyEvent e) {
if (messageComponent.isShowing()) {
messageComponent.removeHierarchyListener(this);
final Window window = SwingUtilities.getWindowAncestor(messageComponent);
if (window instanceof JDialog)
((JDialog) window).setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
window.setIconImages(iconImages);
}
}
});
final int userDecision = JOptionPane.showOptionDialog(UITools.getCurrentFrame(), messageComponent, title, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, remindMeLater);
switch(userDecision) {
case JOptionPane.CLOSED_OPTION:
if (userVisitedVotingLink)
freeplaneSurveyProperties.markSurveyAsFilled(surveyId);
break;
default:
switch(Options.values()[userDecision]) {
case GO_OPTION:
try {
freeplaneSurveyProperties.markSurveyAsFilled(surveyId);
final URL survey = new URL(surveyUrl);
openSurvey(survey);
} catch (Exception e) {
}
break;
case NOT_INTERESTED_OPTION:
freeplaneSurveyProperties.markSurveyAsFilled(surveyId);
break;
case REMIND_ME_LATER_OPTION:
freeplaneSurveyProperties.setNextSurveyDay(MINIMAL_DAYS_BETWEEN_SURVEY_REMINDERS);
freeplaneSurveyProperties.activateRemindMeLater();
break;
case NEVER_OPTION:
freeplaneSurveyProperties.setNeverShowSurvey();
break;
}
}
}
Aggregations