Example usage for javax.swing JTextPane setName

List of usage examples for javax.swing JTextPane setName

Introduction

In this page you can find the example usage for javax.swing JTextPane setName.

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    panel.setLayout(new BorderLayout());
    setContentPane(panel);// w  ww.j  a v  a2s .  c  o  m
    JTextPane textA = new JTextPane();
    textA.setName("text");
    textA.setContentType("text/html");
    DefaultCaret caret = (DefaultCaret) textA.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    JScrollPane filler = new JScrollPane(textA, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    JTextPane textB = new JTextPane();
    textB.setName("text" + "_T");
    textB.setFont(textA.getFont());
    DefaultCaret caret_T = (DefaultCaret) textB.getCaret();
    caret_T.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    JScrollPane filler_T = new JScrollPane(textB, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    panel.add(filler, BorderLayout.NORTH);
    panel.add(filler_T, BorderLayout.CENTER);
    pack();
}

From source file:tufts.vue.ui.InspectorPane.java

private static JComponent buildSummary(final Resource r, final MetaMap data) {
    final JTextPane htmlText = new JTextPane();
    htmlText.setEditable(false);// w ww.  ja  va2  s.  c o  m
    htmlText.setContentType("text/html");
    htmlText.setName("description:" + r);
    htmlText.addHyperlinkListener(DefaultHyperlinkListener);

    //final MetaMap data = (node == null ? null : node.getRawData());

    final String desc = findProperty(r, data, "descriptionSummary", "Description", "Summary");

    final String summary;

    if (desc != null || r == null) {

        summary = buildSummaryWithDescription(r, data, desc);
        if (summary == null || summary.length() == 0)
            return null;
        //htmlText.setText("No Description");// todo: should just hide panel
        else
            htmlText.setText(summary);

        if (DEBUG.DATA && data != null)
            data.put("$reformatted", "[" + summary + "]");

    } else { //if (r != null) {

        //------------------------------------------------------------------
        // No description was found: build a summary from just the Resource
        //------------------------------------------------------------------

        summary = buildSummaryFromResource(r);

        htmlText.setText(summary);

        if (DEBUG.DATA)
            r.setProperty("~reformatted", summary);

    }
    //else return null;

    // This must be done last.  Why this doesn't work up front I don't know: there
    // must be some other way...

    GUI.setDocumentFont(htmlText, GUI.ContentFace);

    return htmlText;

    //         if (loader != null) {
    //             // this not actually helping, other than we get to see "Loading..." before it hangs.
    //             final Thread _loader = loader;
    //             GUI.invokeAfterAWT(new Runnable() { public void run() {
    //                 _loader.start();
    //             }});
    //         }

}