Example usage for javax.swing JEditorPane setPreferredSize

List of usage examples for javax.swing JEditorPane setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JEditorPane setPreferredSize.

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:Main.java

public static void main(String[] args) {
    final JEditorPane editPane1 = new JEditorPane("text/html", "Try ty\tping some tabs");
    editPane1.setPreferredSize(new Dimension(400, 300));
    JOptionPane.showMessageDialog(null, new JScrollPane(editPane1));
    JOptionPane.showMessageDialog(null, new JScrollPane(new JEditorPane("text/html", editPane1.getText())));
}

From source file:Main.java

private JPanel createTabbedPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    JTextField field = new JTextField(50);
    JEditorPane pane = new JEditorPane();
    pane.setPreferredSize(new Dimension(700, 500));

    panel.add(field, BorderLayout.NORTH);
    panel.add(pane, BorderLayout.CENTER);
    return panel;
}

From source file:io.github.jeddict.jpa.modeler.properties.classmember.ClassMemberPanel.java

private String getCode(String code, String title) {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setContentType("text/x-java");
    editorPane.setPreferredSize(new java.awt.Dimension(600, 400));
    editorPane.setText(code);//from www  .j av  a2s. c o m
    OptionDialog dialog = new OptionDialog(editorPane, title);
    dialog.setVisible(true);
    if (OK_OPTION == dialog.getDialogResult()) {
        return editorPane.getText();
    } else {
        return code;
    }
}

From source file:net.sf.housekeeper.swing.MainFrame.java

/**
 * Shows the About dialog for the application.
 *//*from  w w w .j  ava 2s .  c o  m*/
private void showAboutDialog() {
    final JEditorPane editorPane = new JEditorPane();
    editorPane.setEditable(false);
    final String aboutFile = "/net/sf/housekeeper/about.html";
    final URL helpURL = MainFrame.class.getResource(aboutFile);
    if (helpURL != null) {
        try {
            editorPane.setPage(helpURL);
        } catch (IOException ex) {
            LogFactory.getLog(MainFrame.AboutDialogAction.class)
                    .error("Attempted to read a bad URL: " + helpURL, ex);
        }
    } else {
        LogFactory.getLog(MainFrame.AboutDialogAction.class).error("Could not find file: " + aboutFile);
    }

    editorPane.setPreferredSize(new Dimension(400, 200));
    JOptionPane.showMessageDialog(view, editorPane);
}

From source file:net.panthema.BispanningGame.GamePanel.java

public void addPopupActions(JPopupMenu popup) {

    popup.add(new AbstractAction("Center Graph") {
        private static final long serialVersionUID = 571719411574657791L;

        public void actionPerformed(ActionEvent e) {
            centerAndScaleGraph();//from ww  w  .j  ava  2 s.c o  m
        }
    });

    popup.add(new AbstractAction("Relayout Graph") {
        private static final long serialVersionUID = 571719411573657791L;

        public void actionPerformed(ActionEvent e) {
            relayoutGraph();
        }
    });

    popup.add(new AbstractAction("Reset Board Colors") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            mGraph.updateOriginalColor();
            mTurnNum = 0;
            putLog("Resetting game graph's colors.");
            updateGraphMessage();
            mVV.repaint();
        }
    });

    popup.add(new AbstractAction(
            allowFreeExchange ? "Restrict to Unique Exchanges" : "Allow Free Edge Exchanges") {
        private static final long serialVersionUID = 571719411573657798L;

        public void actionPerformed(ActionEvent e) {
            allowFreeExchange = !allowFreeExchange;
            mVV.repaint();
        }
    });

    popup.add(new AbstractAction((mAutoPlayBob ? "Disable" : "Enable") + " Autoplay of Bob's Moves") {
        private static final long serialVersionUID = 571719413573657798L;

        public void actionPerformed(ActionEvent e) {
            mAutoPlayBob = !mAutoPlayBob;
        }
    });

    popup.addSeparator();

    JMenu newGraph = new JMenu("New Random Graph");
    for (int i = 0; i < actionRandomGraph.length; ++i) {
        if (actionRandomGraph[i] != null)
            newGraph.add(actionRandomGraph[i]);
    }
    newGraph.addSeparator();
    newGraph.add(getActionNewGraphType());
    popup.add(newGraph);

    JMenu newNamedGraph = new JMenu("New Named Graph");
    for (int i = 0; i < actionNamedGraph.size(); ++i) {
        if (actionNamedGraph.get(i) != null)
            newNamedGraph.add(actionNamedGraph.get(i));
    }
    popup.add(newNamedGraph);

    popup.add(new AbstractAction("Show GraphString") {
        private static final long serialVersionUID = 545719411573657792L;

        public void actionPerformed(ActionEvent e) {
            JEditorPane text = new JEditorPane("text/plain",
                    GraphString.write_graph(mGraph, mVV.getModel().getGraphLayout()));
            text.setEditable(false);
            text.setPreferredSize(new Dimension(300, 125));
            JOptionPane.showMessageDialog(null, text, "GraphString Serialization",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    });

    popup.add(new AbstractAction("Load GraphString") {
        private static final long serialVersionUID = 8636579131902717983L;

        public void actionPerformed(ActionEvent e) {
            String input = JOptionPane.showInputDialog(null, "Enter GraphString:", "");
            if (input == null)
                return;
            loadGraphString(input);
        }
    });

    popup.add(new AbstractAction("Show graph6") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            JTextArea text = new JTextArea(Graph6.write_graph6(mGraph));
            JOptionPane.showMessageDialog(null, text, "graph6 Serialization", JOptionPane.INFORMATION_MESSAGE);
        }
    });

    popup.add(new AbstractAction("Load graph6/sparse6") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            String input = JOptionPane.showInputDialog(null, "Enter graph6/sparse6 string:", "");
            if (input == null)
                return;
            MyGraph g = Graph6.read_graph6(input);
            setNewGraph(g);
        }
    });

    popup.add(new AbstractAction("Read GraphML") {
        private static final long serialVersionUID = 571719411573657794L;

        public void actionPerformed(ActionEvent e) {
            try {
                readGraphML();
            } catch (IOException e1) {
                showStackTrace(e1);
            } catch (GraphIOException e1) {
                showStackTrace(e1);
            }
        }
    });

    popup.add(new AbstractAction("Write GraphML") {
        private static final long serialVersionUID = 571719411573657795L;

        public void actionPerformed(ActionEvent e) {
            try {
                writeGraphML();
            } catch (IOException e1) {
                showStackTrace(e1);
            }
        }
    });

    popup.add(new AbstractAction("Write PDF") {
        private static final long serialVersionUID = 571719411573657793L;

        public void actionPerformed(ActionEvent e) {
            try {
                writePdf();
            } catch (FileNotFoundException e1) {
                showStackTrace(e1);
            } catch (DocumentException de) {
                System.err.println(de.getMessage());
            }
        }
    });
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * Create if needed and return the editorpane for the description tab
 *
 * @return description view//from  w  w  w  .j  ava2  s . c o  m
 */
private JEditorPane getHtmlView() {
    if (htmlView == null) {
        JEditorPane tmp = new JEditorPane();
        tmp.setContentType("text/html");
        tmp.setPreferredSize(new Dimension(300, 400));
        tmp.setEditable(false);
        tmp.setText(" ");
        htmlView = tmp;
    }
    return htmlView;

}

From source file:org.apache.tika.gui.TikaGUI.java

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);//  ww  w .  ja  v a 2 s. co  m
    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);
}

From source file:org.apache.tika.gui.TikaGUI.java

private void textDialog(String title, URL resource) {
    try {/*from  w  w  w  .  j  a  v a  2s. com*/
        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();
    }
}

From source file:org.apache.tika.gui.TikaGUI.java

public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == EventType.ACTIVATED) {
        try {//from ww  w. j a va 2s .c om
            URL url = e.getURL();
            try (InputStream stream = url.openStream()) {
                JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8));
                editor.setEditable(false);
                editor.setBackground(Color.WHITE);
                editor.setCaretPosition(0);
                editor.setPreferredSize(new Dimension(600, 400));

                String name = url.toString();
                name = name.substring(name.lastIndexOf('/') + 1);

                JDialog dialog = new JDialog(this, "Apache Tika: " + name);
                dialog.add(new JScrollPane(editor));
                dialog.pack();
                dialog.setVisible(true);
            }
        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }
}

From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java

private JPanel prepareAssayInformation() {

    assayInformation.removeAll();//from   w  ww .j a  va2 s.co  m

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);
    currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30));

    Map<String, String> data = getAssayDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    assayInformation.add(currentlyShowingInfo);

    return assayInformation;
}