Search in sources :

Example 81 with JEditorPane

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) StringWriter(java.io.StringWriter) JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension) JDialog(javax.swing.JDialog) PrintWriter(java.io.PrintWriter)

Example 82 with JEditorPane

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

Example 83 with JEditorPane

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) {
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) DefaultCaret(javax.swing.text.DefaultCaret) JEditorPane(javax.swing.JEditorPane) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Dimension(java.awt.Dimension) JDialog(javax.swing.JDialog) LocationFullException(megamek.common.LocationFullException)

Example 84 with JEditorPane

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) {
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) MechView(megamek.common.MechView) DefaultCaret(javax.swing.text.DefaultCaret) JEditorPane(javax.swing.JEditorPane) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Dimension(java.awt.Dimension) LocationFullException(megamek.common.LocationFullException) JDialog(javax.swing.JDialog)

Example 85 with JEditorPane

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));
}
Also used : PrettyPrinter(suite.node.pp.PrettyPrinter) Node(suite.node.Node) JEditorPane(javax.swing.JEditorPane)

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