use of javax.swing.JEditorPane in project tika by apache.
the class TikaGUI method handleError.
private void handleError(String name, Throwable t) {
StringWriter writer = new StringWriter();
writer.append("Apache Tika was unable to parse the document\n");
writer.append("at " + name + ".\n\n");
writer.append("The full exception stack trace is included below:\n\n");
t.printStackTrace(new PrintWriter(writer));
JEditorPane editor = new JEditorPane("text/plain", writer.toString());
editor.setEditable(false);
editor.setBackground(Color.WHITE);
editor.setCaretPosition(0);
editor.setPreferredSize(new Dimension(600, 400));
JDialog dialog = new JDialog(this, "Apache Tika error");
dialog.add(new JScrollPane(editor));
dialog.pack();
dialog.setVisible(true);
}
use of javax.swing.JEditorPane in project tika by apache.
the class TikaGUI method addCard.
private JEditorPane addCard(JPanel panel, String type, String name) {
JEditorPane editor = new JTextPane();
editor.setBackground(Color.WHITE);
editor.setContentType(type);
editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this));
panel.add(new JScrollPane(editor), name);
return editor;
}
use of javax.swing.JEditorPane in project megameklab by MegaMek.
the class UnitUtil method showBVCalculations.
public static void showBVCalculations(String bvText, JFrame frame) {
HTMLEditorKit kit = new HTMLEditorKit();
JEditorPane textPane = new JEditorPane("text/html", "");
JScrollPane scroll = new JScrollPane();
textPane.setEditable(false);
textPane.setCaret(new DefaultCaret());
textPane.setEditorKit(kit);
scroll.setViewportView(textPane);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.getVerticalScrollBar().setUnitIncrement(20);
textPane.setText(bvText);
scroll.setVisible(true);
JDialog jdialog = new JDialog();
jdialog.add(scroll);
Dimension size = new Dimension((int) (CConfig.getIntParam("WINDOWWIDTH") / 1.5), CConfig.getIntParam("WINDOWHEIGHT"));
jdialog.setPreferredSize(size);
jdialog.setMinimumSize(size);
scroll.setPreferredSize(size);
scroll.setMinimumSize(size);
// text.setPreferredSize(size);
jdialog.setLocationRelativeTo(frame);
jdialog.setVisible(true);
try {
textPane.setSelectionStart(0);
textPane.setSelectionEnd(0);
} catch (Exception ex) {
}
}
use of javax.swing.JEditorPane in project megameklab by MegaMek.
the class UnitUtil method showUnitSpecs.
public static void showUnitSpecs(Entity unit, JFrame frame) {
HTMLEditorKit kit = new HTMLEditorKit();
MechView mechView = null;
try {
mechView = new MechView(unit, true);
} catch (Exception e) {
// error unit didn't load right. this is bad news.
}
StringBuffer unitSpecs = new StringBuffer("<html><body>");
unitSpecs.append(mechView.getMechReadoutBasic());
unitSpecs.append(mechView.getMechReadoutLoadout());
unitSpecs.append("</body></html>");
// System.err.println(unitSpecs.toString());
JEditorPane textPane = new JEditorPane("text/html", "");
JScrollPane scroll = new JScrollPane();
textPane.setEditable(false);
textPane.setCaret(new DefaultCaret());
textPane.setEditorKit(kit);
scroll.setViewportView(textPane);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.getVerticalScrollBar().setUnitIncrement(20);
textPane.setText(unitSpecs.toString());
scroll.setVisible(true);
JDialog jdialog = new JDialog();
jdialog.add(scroll);
/*
* if (unit instanceof Mech) { EntityVerifier entityVerifier = new
* EntityVerifier(new File("data/mechfiles/UnitVerifierOptions.xml"));
* //$NON-NLS-1$ TestMech test = new TestMech((Mech)unit,
* entityVerifier.mechOption, null); JEditorPane pane2 = new
* JEditorPane();
* pane2.setText(test.printWeightCalculation().toString());
* jdialog.add(pane2); }
*/
Dimension size = new Dimension(CConfig.getIntParam("WINDOWWIDTH") / 2, CConfig.getIntParam("WINDOWHEIGHT"));
jdialog.setPreferredSize(size);
jdialog.setMinimumSize(size);
scroll.setPreferredSize(size);
scroll.setMinimumSize(size);
// text.setPreferredSize(size);
jdialog.setLocationRelativeTo(frame);
jdialog.setVisible(true);
try {
textPane.setSelectionStart(0);
textPane.setSelectionEnd(0);
} catch (Exception ex) {
}
}
use of javax.swing.JEditorPane in project suite by stupidsing.
the class EditorController method format.
public void format() {
JEditorPane editor = view.getEditor();
Node node = Suite.parse(editor.getText());
editor.setText(new PrettyPrinter().prettyPrint(node));
}
Aggregations