Search in sources :

Example 46 with JEditorPane

use of javax.swing.JEditorPane in project jdk8u_jdk by JetBrains.

the class LargeQuickDoc method main.

public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(() -> {
        JFrame f = new JFrame();
        JEditorPane editorPane = new javax.swing.JEditorPane("text/html", "");
        editorPane.setEditorKit(new HTMLEditorKit());
        editorPane.setEditable(false);
        JScrollPane scrollPane = new JScrollPane(editorPane);
        scrollPane.setBorder(null);
        try {
            editorPane.setText(getText());
        } catch (IOException | ArrayIndexOutOfBoundsException e) {
            throw new RuntimeException(e);
        }
        f.getContentPane().add(scrollPane);
        f.setSize(500, 500);
        f.setVisible(true);
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) IOException(java.io.IOException)

Example 47 with JEditorPane

use of javax.swing.JEditorPane in project jmeter by apache.

the class SamplerResultTab method createResponseDataPanel.

private JPanel createResponseDataPanel() {
    results = new JEditorPane();
    results.setEditable(false);
    resultsScrollPane = GuiUtils.makeScrollPane(results);
    imageLabel = new JLabel();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(resultsScrollPane, BorderLayout.CENTER);
    if (activateSearchExtension) {
        // Add search text extension
        searchTextExtension = new SearchTextExtension();
        searchTextExtension.init(panel);
        searchPanel = searchTextExtension.createSearchTextExtensionPane();
        searchTextExtension.setResults(results);
        searchPanel.setVisible(true);
        panel.add(searchPanel, BorderLayout.PAGE_END);
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JEditorPane(javax.swing.JEditorPane) JLabel(javax.swing.JLabel)

Example 48 with JEditorPane

use of javax.swing.JEditorPane in project jabref by JabRef.

the class PreviewPanelTransferHandler method createTransferable.

@Override
protected Transferable createTransferable(JComponent component) {
    if (component instanceof JEditorPane) {
        // this method should be called from the preview panel only
        // the default TransferHandler implementation is aware of HTML
        // and returns an appropriate Transferable
        // as textTransferHandler.createTransferable() is not available and
        // I don't know any other method, I do the HTML conversion by hand
        // First, get the HTML of the selected text
        JEditorPane editorPane = (JEditorPane) component;
        StringWriter stringWriter = new StringWriter();
        try {
            editorPane.getEditorKit().write(stringWriter, editorPane.getDocument(), editorPane.getSelectionStart(), editorPane.getSelectionEnd());
        } catch (BadLocationException | IOException e) {
            LOGGER.warn("Cannot write preview", e);
        }
        // Second, return the HTML (and text as fallback)
        return new HtmlTransferable(stringWriter.toString(), editorPane.getSelectedText());
    } else {
        // if not called from the preview panel, return an error string
        return new StringSelection(Localization.lang("Operation not supported"));
    }
}
Also used : StringWriter(java.io.StringWriter) JEditorPane(javax.swing.JEditorPane) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException) StringSelection(java.awt.datatransfer.StringSelection)

Example 49 with JEditorPane

use of javax.swing.JEditorPane in project jgnash by ccavanaugh.

the class BudgetWizardDialog method initComponents.

private void initComponents() {
    okButton = new JButton(rb.getString("Button.Ok"));
    cancelButton = new JButton(rb.getString("Button.Cancel"));
    budgetPeriodCombo = new JComboBox<>();
    budgetPeriodCombo.setModel(new DefaultComboBoxModel<>(Period.values()));
    budgetPeriodCombo.setSelectedItem(Period.MONTHLY);
    budgetNameField = new JTextField();
    DefaultUnitConverter unitConverter = DefaultUnitConverter.getInstance();
    helpPane = new JEditorPane();
    helpPane.setEditable(false);
    helpPane.setEditorKit(new StyledEditorKit());
    helpPane.setBackground(getBackground());
    helpPane.setText(TextResource.getString("NewBudgetOne.txt"));
    helpPane.setPreferredSize(new Dimension(unitConverter.dialogUnitXAsPixel(DLU_X, helpPane), unitConverter.dialogUnitYAsPixel(DLU_Y, helpPane)));
    roundButton = new JCheckBox(rb.getString("Button.RoundToWhole"));
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);
}
Also used : StyledEditorKit(javax.swing.text.StyledEditorKit) JCheckBox(javax.swing.JCheckBox) JButton(javax.swing.JButton) JEditorPane(javax.swing.JEditorPane) DefaultUnitConverter(com.jgoodies.forms.util.DefaultUnitConverter) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 50 with JEditorPane

use of javax.swing.JEditorPane in project jgnash by ccavanaugh.

the class NewFileThree method initComponents.

private void initComponents() {
    addButton = new JButton(rb.getString("Button.Add"));
    addButton.setIcon(IconUtils.getIcon("/jgnash/resource/list-add.png"));
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    removeButton = new JButton(rb.getString("Button.Remove"));
    removeButton.setIcon(IconUtils.getIcon("/jgnash/resource/list-remove.png"));
    aJList = new JList<>();
    cJList = new JList<>();
    helpPane = new JEditorPane();
    helpPane.setEditable(false);
    helpPane.setEditorKit(new StyledEditorKit());
    helpPane.setBackground(getBackground());
    helpPane.setText(TextResource.getString("NewFileThree.txt"));
    addButton.addActionListener(this);
    removeButton.addActionListener(this);
}
Also used : StyledEditorKit(javax.swing.text.StyledEditorKit) JButton(javax.swing.JButton) JEditorPane(javax.swing.JEditorPane)

Aggregations

JEditorPane (javax.swing.JEditorPane)60 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)12 JPanel (javax.swing.JPanel)12 IOException (java.io.IOException)11 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)11 JFrame (javax.swing.JFrame)10 GridBagLayout (java.awt.GridBagLayout)9 GridBagConstraints (java.awt.GridBagConstraints)8 JDialog (javax.swing.JDialog)7 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 BorderLayout (java.awt.BorderLayout)5 JTextField (javax.swing.JTextField)5 HyperlinkListener (javax.swing.event.HyperlinkListener)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3