Search in sources :

Example 91 with JEditorPane

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();
}
Also used : JEditorPane(javax.swing.JEditorPane) ProjectHistoryException(teamdash.hist.ProjectHistoryException)

Example 92 with JEditorPane

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) JEditorPane(javax.swing.JEditorPane) URL(java.net.URL) Font(java.awt.Font)

Example 93 with JEditorPane

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) Enumeration(java.util.Enumeration) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane)

Example 94 with JEditorPane

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);
}
Also used : JEditorPane(javax.swing.JEditorPane)

Example 95 with JEditorPane

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;
            }
    }
}
Also used : Window(java.awt.Window) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JButton(javax.swing.JButton) Image(java.awt.Image) URL(java.net.URL) HierarchyListener(java.awt.event.HierarchyListener) HyperlinkListener(javax.swing.event.HyperlinkListener) HierarchyEvent(java.awt.event.HierarchyEvent) JEditorPane(javax.swing.JEditorPane) JDialog(javax.swing.JDialog)

Aggregations

JEditorPane (javax.swing.JEditorPane)130 JScrollPane (javax.swing.JScrollPane)54 Dimension (java.awt.Dimension)34 JPanel (javax.swing.JPanel)34 JButton (javax.swing.JButton)22 JLabel (javax.swing.JLabel)21 BorderLayout (java.awt.BorderLayout)20 IOException (java.io.IOException)16 HyperlinkEvent (javax.swing.event.HyperlinkEvent)16 JFrame (javax.swing.JFrame)15 HyperlinkListener (javax.swing.event.HyperlinkListener)15 JDialog (javax.swing.JDialog)14 GridBagConstraints (java.awt.GridBagConstraints)12 GridBagLayout (java.awt.GridBagLayout)12 URL (java.net.URL)12 ActionEvent (java.awt.event.ActionEvent)11 FlowLayout (java.awt.FlowLayout)10 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)10 Component (java.awt.Component)9 JSplitPane (javax.swing.JSplitPane)9