Search in sources :

Example 96 with JEditorPane

use of javax.swing.JEditorPane in project Spark by igniterealtime.

the class FastpathRes method main.

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout());
    JEditorPane pane = new JEditorPane();
    frame.getContentPane().add(new JScrollPane(pane));
    StringBuffer buf = new StringBuffer();
    Enumeration<String> enumeration = prb.getKeys();
    while (enumeration.hasMoreElements()) {
        String token = enumeration.nextElement();
        String value = prb.getString(token).toLowerCase();
        if (value.endsWith(".gif") || value.endsWith(".png") || value.endsWith(".jpg") || value.endsWith("jpeg")) {
            FastpathRes.getImageIcon(token);
        }
        String str = "public static final String " + token + " = \"" + token + "\";\n";
        buf.append(str);
    }
    checkImageDir();
    pane.setText(buf.toString());
    frame.pack();
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane)

Example 97 with JEditorPane

use of javax.swing.JEditorPane in project blue by kunstmusik.

the class BSBCompletionItemTest method testReplaceWordBeforeCaret.

/**
 * Test of replaceWordBeforeCaret method, of class BSBCompletionItem.
 */
@Test
public void testReplaceWordBeforeCaret() {
    String replacementText = "<test>";
    JTextComponent jtc = new JEditorPane();
    jtc.setText("<");
    jtc.setCaretPosition(1);
    BSBCompletionItem instance = new BSBCompletionItem(new BSBKnob(), "test");
    instance.replaceWordBeforeCaret(replacementText, jtc);
    assertEquals("<test>", jtc.getText());
}
Also used : BSBKnob(blue.orchestra.blueSynthBuilder.BSBKnob) JEditorPane(javax.swing.JEditorPane) JTextComponent(javax.swing.text.JTextComponent) Test(org.junit.Test)

Example 98 with JEditorPane

use of javax.swing.JEditorPane in project mdw-designer by CenturyLinkCloud.

the class ExportHelper method printHtmlParagraphsPdf.

private void printHtmlParagraphsPdf(Section section, String content, int parentLevel) throws Exception {
    if (content == null || content.length() == 0)
        return;
    String vContent = content;
    if (isBase64Encoded(content) || "true".equals(System.getProperty("mdw.designer.force.msword"))) {
        byte[] docBytes = decodeBase64(content);
        vContent = new DocxBuilder(docBytes).toHtml();
        vContent = vContent.replaceAll("&nbsp;", "&#160;");
    }
    JEditorPane documentation = new JEditorPane();
    documentation.setContentType("text/html");
    documentation.setText(vContent);
    javax.swing.text.Document swingdoc = documentation.getDocument();
    Element[] elements = swingdoc.getRootElements();
    for (Element e : elements) {
        Object gen = generateElementHtml(e, 0, normalFont);
        addSectionContentPdf(section, gen, parentLevel);
    }
}
Also used : DocxBuilder(com.centurylink.mdw.designer.utils.DocxBuilder) AbstractElement(javax.swing.text.AbstractDocument.AbstractElement) Element(javax.swing.text.Element) JEditorPane(javax.swing.JEditorPane)

Example 99 with JEditorPane

use of javax.swing.JEditorPane in project bioformats by openmicroscopy.

the class MainDialog method rebuildDialog.

// -- Helper methods --
/**
 * Fancies up the importer dialog to look much nicer.
 */
private void rebuildDialog(GenericDialog gd) {
    // extract GUI components from dialog and add listeners
    List<Checkbox> boxes = null;
    List<Choice> choices = null;
    List<Label> labels = null;
    Label colorModeLabel = null;
    Label roisModeLabel = null;
    Label stackFormatLabel = null;
    Label stackOrderLabel = null;
    Component[] c = gd.getComponents();
    if (c != null) {
        boxes = new ArrayList<Checkbox>();
        choices = new ArrayList<Choice>();
        labels = new ArrayList<Label>();
        for (int i = 0; i < c.length; i++) {
            if (c[i] instanceof Checkbox) {
                Checkbox item = (Checkbox) c[i];
                item.addFocusListener(this);
                item.addItemListener(this);
                item.addMouseListener(this);
                boxes.add(item);
            } else if (c[i] instanceof Choice) {
                Choice item = (Choice) c[i];
                item.addFocusListener(this);
                item.addItemListener(this);
                item.addMouseListener(this);
                choices.add(item);
            } else if (c[i] instanceof Label)
                labels.add((Label) c[i]);
        }
        int boxIndex = 0, choiceIndex = 0, labelIndex = 0;
        autoscaleBox = boxes.get(boxIndex++);
        colorModeChoice = choices.get(choiceIndex++);
        colorModeLabel = labels.get(labelIndex++);
        concatenateBox = boxes.get(boxIndex++);
        cropBox = boxes.get(boxIndex++);
        groupFilesBox = boxes.get(boxIndex++);
        ungroupFilesBox = boxes.get(boxIndex++);
        openAllSeriesBox = boxes.get(boxIndex++);
        // quiet
        boxIndex++;
        // recordBox         = boxes.get(boxIndex++);
        showMetadataBox = boxes.get(boxIndex++);
        showOMEXMLBox = boxes.get(boxIndex++);
        showROIsBox = boxes.get(boxIndex++);
        roisModeChoice = choices.get(choiceIndex++);
        roisModeLabel = labels.get(labelIndex++);
        specifyRangesBox = boxes.get(boxIndex++);
        splitZBox = boxes.get(boxIndex++);
        splitTBox = boxes.get(boxIndex++);
        splitCBox = boxes.get(boxIndex++);
        stackFormatChoice = choices.get(choiceIndex++);
        stackFormatLabel = labels.get(labelIndex++);
        stackOrderChoice = choices.get(choiceIndex++);
        stackOrderLabel = labels.get(labelIndex++);
        swapDimsBox = boxes.get(boxIndex++);
        virtualBox = boxes.get(boxIndex++);
        stitchTilesBox = boxes.get(boxIndex++);
    }
    verifyOptions(null);
    // TODO: The info table and focus logic could be split into
    // its own class, rather than being specific to this dialog.
    // associate information for each option
    infoTable = new HashMap<Component, String>();
    infoTable.put(autoscaleBox, options.getAutoscaleInfo());
    infoTable.put(colorModeChoice, options.getColorModeInfo());
    infoTable.put(colorModeLabel, options.getColorModeInfo());
    infoTable.put(concatenateBox, options.getConcatenateInfo());
    infoTable.put(cropBox, options.getCropInfo());
    infoTable.put(groupFilesBox, options.getGroupFilesInfo());
    infoTable.put(ungroupFilesBox, options.getUngroupFilesInfo());
    infoTable.put(openAllSeriesBox, options.getOpenAllSeriesInfo());
    // infoTable.put(recordBox, options.getRecordInfo());
    infoTable.put(showMetadataBox, options.getShowMetadataInfo());
    infoTable.put(showOMEXMLBox, options.getShowOMEXMLInfo());
    infoTable.put(showROIsBox, options.getShowROIsInfo());
    infoTable.put(roisModeChoice, options.getROIsModeInfo());
    infoTable.put(roisModeLabel, options.getROIsModeInfo());
    infoTable.put(specifyRangesBox, options.getSpecifyRangesInfo());
    infoTable.put(splitZBox, options.getSplitFocalPlanesInfo());
    infoTable.put(splitTBox, options.getSplitTimepointsInfo());
    infoTable.put(splitCBox, options.getSplitChannelsInfo());
    infoTable.put(stackFormatChoice, options.getStackFormatInfo());
    infoTable.put(stackFormatLabel, options.getStackFormatInfo());
    infoTable.put(stackOrderChoice, options.getStackOrderInfo());
    infoTable.put(stackOrderLabel, options.getStackOrderInfo());
    infoTable.put(swapDimsBox, options.getSwapDimensionsInfo());
    infoTable.put(virtualBox, options.getVirtualInfo());
    infoTable.put(stitchTilesBox, options.getStitchTilesInfo());
    // rebuild dialog using FormLayout to organize things more nicely
    String cols = // first column
    "pref, 3dlu, pref:grow, " + // second column
    "10dlu, pref, 3dlu, pref:grow, " + // third column
    "10dlu, fill:150dlu";
    String rows = // Stack viewing        | Metadata viewing
    "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, " + // Dataset organization | Memory management
    "9dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, " + "3dlu, pref, " + // Color options        | Split into separate windows
    "9dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref";
    // TODO: Change "Use virtual stack" and "Record modifications to virtual
    // stack" checkboxes to "Stack type" choice with options:
    // "Normal", "Virtual" or "Smart virtual"
    PanelBuilder builder = new PanelBuilder(new FormLayout(cols, rows));
    CellConstraints cc = new CellConstraints();
    // populate 1st column
    int row = 1;
    builder.addSeparator("Stack viewing", cc.xyw(1, row, 3));
    row += 2;
    builder.add(stackFormatLabel, cc.xy(1, row));
    builder.add(stackFormatChoice, cc.xy(3, row));
    row += 2;
    builder.add(stackOrderLabel, cc.xy(1, row));
    builder.add(stackOrderChoice, cc.xy(3, row));
    row += 6;
    builder.addSeparator("Dataset organization", cc.xyw(1, row, 3));
    row += 2;
    builder.add(groupFilesBox, xyw(cc, 1, row, 3));
    row += 2;
    builder.add(ungroupFilesBox, xyw(cc, 1, row, 3));
    row += 2;
    builder.add(swapDimsBox, xyw(cc, 1, row, 3));
    row += 2;
    builder.add(openAllSeriesBox, xyw(cc, 1, row, 3));
    row += 2;
    builder.add(concatenateBox, xyw(cc, 1, row, 3));
    row += 2;
    builder.add(stitchTilesBox, xyw(cc, 1, row, 3));
    row += 2;
    builder.addSeparator("Color options", cc.xyw(1, row, 3));
    row += 2;
    builder.add(colorModeLabel, cc.xy(1, row));
    builder.add(colorModeChoice, cc.xy(3, row));
    row += 2;
    builder.add(autoscaleBox, xyw(cc, 1, row, 3));
    row += 2;
    // populate 2nd column
    row = 1;
    builder.addSeparator("Metadata viewing", cc.xyw(5, row, 3));
    row += 2;
    builder.add(showMetadataBox, xyw(cc, 5, row, 3));
    row += 2;
    builder.add(showOMEXMLBox, xyw(cc, 5, row, 3));
    row += 2;
    builder.add(showROIsBox, xyw(cc, 5, row, 3));
    row += 2;
    builder.add(roisModeLabel, cc.xy(5, row));
    builder.add(roisModeChoice, cc.xy(7, row));
    row += 2;
    builder.addSeparator("Memory management", cc.xyw(5, row, 3));
    row += 2;
    builder.add(virtualBox, xyw(cc, 5, row, 3));
    row += 2;
    // builder.add(recordBox, xyw(cc, 5, row, 3));
    // row += 2;
    builder.add(specifyRangesBox, xyw(cc, 5, row, 3));
    row += 2;
    builder.add(cropBox, xyw(cc, 5, row, 3));
    row += 4;
    builder.addSeparator("Split into separate windows", cc.xyw(5, row, 3));
    row += 2;
    builder.add(splitCBox, xyw(cc, 5, row, 3));
    row += 2;
    builder.add(splitZBox, xyw(cc, 5, row, 3));
    row += 2;
    builder.add(splitTBox, xyw(cc, 5, row, 3));
    // row += 4;
    // information section
    builder.addSeparator("Information", cc.xy(9, 1));
    // row += 2;
    infoPane = new JEditorPane();
    infoPane.setContentType("text/html");
    infoPane.setEditable(false);
    infoPane.setText("<html>" + INFO_DEFAULT);
    builder.add(new JScrollPane(infoPane), cc.xywh(9, 3, 1, row));
    // row += 2;
    gd.removeAll();
    gd.add(builder.getPanel());
    WindowTools.addScrollBars(gd);
    // HACK: workaround for JPanel in a Dialog
    gd.setBackground(Color.white);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JScrollPane(javax.swing.JScrollPane) PanelBuilder(com.jgoodies.forms.builder.PanelBuilder) Choice(java.awt.Choice) Label(java.awt.Label) Checkbox(java.awt.Checkbox) JEditorPane(javax.swing.JEditorPane) Component(java.awt.Component) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 100 with JEditorPane

use of javax.swing.JEditorPane in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method doHelp.

/**
 * This method displays the help html.
 */
private Runner doHelp() {
    if (wrap)
        return wrapMe();
    try {
        int w = OurUtil.getScreenWidth(), h = OurUtil.getScreenHeight();
        final JFrame frame = new JFrame();
        final JEditorPane html1 = new JEditorPane("text/html", "");
        final JEditorPane html2 = new JEditorPane("text/html", "");
        final HTMLDocument doc1 = (HTMLDocument) (html1.getDocument());
        doc1.setAsynchronousLoadPriority(-1);
        final HTMLDocument doc2 = (HTMLDocument) (html2.getDocument());
        doc2.setAsynchronousLoadPriority(-1);
        html1.setPage(this.getClass().getResource("/help/Nav.html"));
        html2.setPage(this.getClass().getResource("/help/index.html"));
        HyperlinkListener hl = new HyperlinkListener() {

            @Override
            public final void hyperlinkUpdate(HyperlinkEvent e) {
                try {
                    if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
                        return;
                    if (e.getURL().getPath().endsWith("quit.htm")) {
                        frame.dispose();
                        return;
                    }
                    HTMLDocument doc = (HTMLDocument) (html2.getDocument());
                    // So that we can
                    doc.setAsynchronousLoadPriority(-1);
                    // catch any
                    // exception
                    // that may
                    // occur
                    html2.setPage(e.getURL());
                    html2.requestFocusInWindow();
                } catch (Throwable ex) {
                }
            }
        };
        html1.setEditable(false);
        html1.setBorder(new EmptyBorder(3, 3, 3, 3));
        html1.addHyperlinkListener(hl);
        html2.setEditable(false);
        html2.setBorder(new EmptyBorder(3, 3, 3, 3));
        html2.addHyperlinkListener(hl);
        JScrollPane scroll1 = OurUtil.scrollpane(html1);
        JScrollPane scroll2 = OurUtil.scrollpane(html2);
        JSplitPane split = OurUtil.splitpane(JSplitPane.HORIZONTAL_SPLIT, scroll1, scroll2, 150);
        split.setResizeWeight(0d);
        frame.setTitle("Alloy Analyzer Online Guide");
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(split, BorderLayout.CENTER);
        frame.pack();
        frame.setSize(w - w / 10, h - h / 10);
        frame.setLocation(w / 20, h / 20);
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.setVisible(true);
        html2.requestFocusInWindow();
    } catch (Throwable ex) {
        return null;
    }
    return null;
}
Also used : JScrollPane(javax.swing.JScrollPane) HyperlinkEvent(javax.swing.event.HyperlinkEvent) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) HyperlinkListener(javax.swing.event.HyperlinkListener) HTMLDocument(javax.swing.text.html.HTMLDocument) JEditorPane(javax.swing.JEditorPane) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane)

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