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);
});
}
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"));
}
}
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);
}
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);
}
use of javax.swing.JEditorPane in project tika by apache.
the class TikaGUI method textDialog.
private void textDialog(String title, URL resource) {
try {
JDialog dialog = new JDialog(this, title);
JEditorPane editor = new JEditorPane(resource);
editor.setContentType("text/html");
editor.setEditable(false);
editor.setBackground(Color.WHITE);
editor.setPreferredSize(new Dimension(400, 250));
editor.addHyperlinkListener(this);
dialog.add(editor);
dialog.pack();
dialog.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations