當前位置: 首頁>>代碼示例>>Java>>正文


Java JEditorPane.setText方法代碼示例

本文整理匯總了Java中javax.swing.JEditorPane.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.setText方法的具體用法?Java JEditorPane.setText怎麽用?Java JEditorPane.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addClassNameEditorCC

import javax.swing.JEditorPane; //導入方法依賴的package包/類
static Pair<JScrollPane, JEditorPane> addClassNameEditorCC(String mimeType, JComponent comp, String className, String tooltipText) {
    JComponent [] editorComponents = Utilities.createSingleLineEditor(mimeType);
    JScrollPane sle = (JScrollPane) editorComponents[0];
    JEditorPane epClassName = (JEditorPane) editorComponents[1];
    epClassName.setText(className);
    if (comp != null) {
        java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        comp.add(sle, gridBagConstraints);
    }
    sle.setToolTipText(tooltipText);
    epClassName.setToolTipText(tooltipText);
    return Pair.<JScrollPane, JEditorPane>of(sle, epClassName);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:ClassBreakpointPanel.java

示例2: getContentHeight

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Calculates the preferred height of an editor pane with the given fixed width for the
 * specified string.
 *
 * @param comment
 *            the annotation comment string
 * @param width
 *            the width of the content
 * @return the preferred height given the comment
 */
public static int getContentHeight(final String comment, final int width) {
	if (comment == null) {
		throw new IllegalArgumentException("comment must not be null!");
	}
	JEditorPane dummyEditorPane = new JEditorPane("text/html", "");
	dummyEditorPane.setText(comment);
	dummyEditorPane.setBorder(null);
	dummyEditorPane.setSize(width, Short.MAX_VALUE);

	// height is not exact. Multiply by magic number to get a more fitting value...
	if (SystemInfoUtilities.getOperatingSystem() == OperatingSystem.OSX
			|| SystemInfoUtilities.getOperatingSystem() == OperatingSystem.UNIX
			|| SystemInfoUtilities.getOperatingSystem() == OperatingSystem.SOLARIS) {
		return (int) (dummyEditorPane.getPreferredSize().getHeight() * 1.05f);
	} else {
		return (int) dummyEditorPane.getPreferredSize().getHeight();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:29,代碼來源:AnnotationDrawUtils.java

示例3: showLicense

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Brings up a dialog that displays the license.
 */
private void showLicense() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.license.title"));
    final JEditorPane text = new JEditorPane();
    try {
        URL url = getClass().getResource("GNULicense.txt");

        text.setPage(url);
    } catch (Exception el) {
        text.setText(resources.getString("dialog.license.error"));
    }
    text.setEditable(false);
    JScrollPane sp = new JScrollPane(text);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
}
 
開發者ID:CBSkarmory,項目名稱:AWGW,代碼行數:22,代碼來源:WorldFrame.java

示例4: getErrorMessage

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private JEditorPane getErrorMessage() {
    JEditorPane errorMsg = new JEditorPane();

    errorMsg.setEditable(false);
    errorMsg.setPreferredSize(new Dimension(700, 130));
    errorMsg.setBackground(null);
    // Text font
    Font font = new Font("Sans", Font.PLAIN, 6);
    errorMsg.setFont(font);
    // Handle HTML
    errorMsg.setEditorKit(new HTMLEditorKit());
    errorMsg.addHyperlinkListener(this);

    errorMsg.setText(ERROR_MSG);

    return errorMsg;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:18,代碼來源:BugReportDialog.java

示例5: createComponent

import javax.swing.JEditorPane; //導入方法依賴的package包/類
@Override
public JComponent createComponent() {
    JScrollPane pane = new JScrollPane();
    editorPane = new JEditorPane();
    pane.setViewportView(editorPane);
    if (scriptPath.endsWith(".js"))
        editorPane.setContentType("text/javascript");
    byte[] bs = framework.getEngine().getStream(scriptPath);
    if (bs == null)
        bs = new byte[]{};
    try {
        editorPane.setText(new String(bs, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    if (!saveScriptAction.isEnabled())
        editorPane.setEditable(false);
    return pane;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:20,代碼來源:ScriptEditor.java

示例6: MyFrame

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public MyFrame() {
    JEditorPane editpane = new JEditorPane();
    editpane.setEditable(false);
    editpane.setText(content);
    editpane.setCaretPosition(0);

    JScrollPane scrollpane = new JScrollPane(editpane);

    add(scrollpane);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setSize(new Dimension(200, 200));
    bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
    setResizable(false);
    setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:SynthScrollbarThumbPainterTest.java

示例7: testMultiDocs

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void testMultiDocs() throws Exception {
    JEditorPane pane = new JEditorPane();
    pane.setText("abc ax ec ajo");
    JFrame frame = new JFrame();
    frame.getContentPane().add(pane);
    frame.pack(); // Allows to EditorRegistry.register() to make an item in the component list
    EditorApiPackageAccessor.get().setIgnoredAncestorClass(JEditorPane.class);
    EditorApiPackageAccessor.get().register(pane);
    
    Document doc = new PlainDocument();
    WordMatch wordMatch = WordMatch.get(doc);
    //                   012345678901234567890123456789
    doc.insertString(0, "abc a x ahoj", null);
    int docLen = doc.getLength();
    int offset = 5;
    wordMatch.matchWord(offset, false);
    compareText(doc, offset - 1, "abc ", docLen + 2);
    wordMatch.matchWord(offset, false);
    compareText(doc, offset - 1, "ahoj ", docLen + 3);
    wordMatch.matchWord(offset, false);
    compareText(doc, offset - 1, "ax ", docLen + 1);
    wordMatch.matchWord(offset, false);
    compareText(doc, offset - 1, "ajo ", docLen + 2);
    wordMatch.matchWord(offset, false);
    compareText(doc, offset - 1, "ajo ", docLen + 2);
    pane.setText(""); // Ensure this doc would affect WordMatch for other docs
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:WordMatchTest.java

示例8: refreshPreview

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public @Override void refreshPreview() {
    JEditorPane pane = (JEditorPane) getPreviewComponent();
    pane.getDocument().putProperty(SimpleValueNames.TEXT_LINE_WRAP, ""); //NOI18N
    pane.getDocument().putProperty(SimpleValueNames.TAB_SIZE, ""); //NOI18N
    pane.getDocument().putProperty(SimpleValueNames.INDENT_SHIFT_WIDTH, prefs.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, 4));
    pane.getDocument().putProperty(SimpleValueNames.SPACES_PER_TAB, prefs.getInt(SimpleValueNames.SPACES_PER_TAB, 4));
    pane.getDocument().putProperty(SimpleValueNames.TEXT_LIMIT_WIDTH, ""); //NOI18N
    pane.setText(previewText);
    
    final Document doc = pane.getDocument();
    if (doc instanceof BaseDocument) {
        final Reformat reformat = Reformat.get(doc);
        reformat.lock();
        try {
            ((BaseDocument) doc).runAtomic(new Runnable() {
                public @Override void run() {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Refreshing preview: expandTabs=" + IndentUtils.isExpandTabs(doc) //NOI18N
                                + ", indentLevelSize=" + IndentUtils.indentLevelSize(doc) //NOI18N
                                + ", tabSize=" + IndentUtils.tabSize(doc) //NOI18N
                                + ", mimeType='" + doc.getProperty("mimeType") + "'" //NOI18N
                                + ", doc=" + s2s(doc)); //NOI18N
                    }

                    try {
                        reformat.reformat(0, doc.getLength());
                    } catch (BadLocationException ble) {
                        LOG.log(Level.WARNING, null, ble);
                    }
                }
            });
        } finally {
            reformat.unlock();
        }
    } else {
        LOG.warning("Can't format " + doc + "; it's not BaseDocument."); //NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:IndentationPanel.java

示例9: redraw

import javax.swing.JEditorPane; //導入方法依賴的package包/類
@Override
public void redraw() {
	// Redraws only if data has changed - Bertoli Marco
	if (!redrawNeeded)
		return;

	if (data.hasResults() && data.areResultsOK()
			&& data.getResults().getSaturationSectors().size() > 0) {
		if (data.getClasses() == 2) {
			this.removeAll();
			s2dp = new Sectors2DGraph(data);
			this.setLayout(new BorderLayout());
			this.add(new JabaCanvas(s2dp), BorderLayout.CENTER);
			this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
					BorderLayout.PAGE_END);
			repaint();
		} else if (data.getClasses() == 3) {
			this.removeAll();
			Sectors3DGraph s3dp = new Sectors3DGraph(data);
			this.setLayout(new BorderLayout());
			this.add(new JabaCanvas(s3dp), BorderLayout.CENTER);
			this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
					BorderLayout.PAGE_END);
			repaint();
		}
	} else {
		this.removeAll();
		JEditorPane synView = new JTextPane();
		synView.setContentType("text/html");
		synView.setEditable(false);
		JScrollPane synScroll = new JScrollPane(synView);
		synScroll
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		synScroll
				.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
		synView.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
		this.add(synScroll, BorderLayout.CENTER);
	}
	redrawNeeded = false;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:41,代碼來源:SectorsGraphicPanel.java

示例10: showHelp

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Brings up a window with a scrolling text pane that display the help
 * information.
 */
private void showHelp() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.help.title"));
    final JEditorPane helpText = new JEditorPane();
    try {
        URL url = getClass().getResource("GridWorldHelp.html");

        helpText.setPage(url);
    } catch (Exception eh) {
        helpText.setText(resources.getString("dialog.help.error"));
    }
    helpText.setEditable(false);
    helpText.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent ev) {
            if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
                try {
                    helpText.setPage(ev.getURL());
                } catch (Exception ex) {
                }
        }
    });
    JScrollPane sp = new JScrollPane(helpText);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
}
 
開發者ID:CBSkarmory,項目名稱:AWGW,代碼行數:32,代碼來源:WorldFrame.java

示例11: redraw

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void redraw() {
	// We redraw only if data has changed - Sebastiano Spicuglia
	if (!redrawNeeded)
		return;
	this.removeAll();
	if (data.hasResults() && data.areResultsOK()
			&& data.getResults().getSaturationSectors().size() > 0) {
		if (data.getClasses() == 2) {
			this.removeAll();
			this.setLayout(new GridLayout(2, 1));
			JPanel tmp = new JPanel(new GridLayout(1, 2));
			tmp.add(new JabaCanvas(new Sectors2DGraph(data)));
			tmp.add(new JabaCanvas(new Convex2DGraph(data, mainWin)));
			this.add(tmp);
			this.add(new JabaCanvas(new PerformanceIndices2DGraph(data)));
			repaint();
		} else if (data.getClasses() == 3) {
			this.removeAll();
			this.setLayout(new GridLayout(1, 2));
			this.add(new JabaCanvas(new Sectors3DGraph(data)));
			this.add(new JabaCanvas(new Convex3DGraph(data, mainWin)));
			repaint();
		}
	} else {
		JEditorPane synView = new JTextPane();
		synView.setContentType("text/html");
		synView.setEditable(false);
		JScrollPane synScroll = new JScrollPane(synView);
		synScroll
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		synScroll
				.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
		synView.setText("<html><body><center><font face=\"bold\" size=\"3\">Graphs will be here displayed once you solve the model.</font></center></body></html>");
		this.add(synScroll);
		repaint();
	}
	redrawNeeded = false;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:39,代碼來源:AllInOnePanel.java

示例12: redraw

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void redraw() {
	// Redraws only if data has changed - Bertoli Marco
	if (old_data == data) {
		return;
	} else {
		old_data = data;
	}

	if (data.hasResults() && data.areResultsOK() && data.getResults().size() > 0) {
		if (data.getClasses() == 2) {
			this.removeAll();
			Sectors2DPanel s2dp = new Sectors2DPanel(data.getResults(), data.getClassNames());
			this.add(s2dp);
			repaint();
		} else if (data.getClasses() == 3) {
			this.removeAll();
			Sectors3DPanel s3dp = new Sectors3DPanel(data.getResults(), data.getClassNames());
			this.add(s3dp);
			repaint();
		}
	} else {
		this.removeAll();
		JEditorPane synView = new JTextPane();
		synView.setContentType("text/html");
		synView.setEditable(false);
		JScrollPane synScroll = new JScrollPane(synView);
		synScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		synScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
		synView
				.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
		this.add(synScroll);
	}
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:34,代碼來源:JabaWizard.java

示例13: getHardwareReportComponent

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public static JComponent getHardwareReportComponent(CLPlatform platform) {
    List<Map<String, Object>> list = listInfos(platform);
    final String html = toHTML(list);

    JEditorPane ed = new JEditorPane();
    ed.setContentType("text/html");
    ed.setText(html);
    ed.setEditable(false);

    JPanel ret = new JPanel(new BorderLayout());
    ret.add("Center", new JScrollPane(ed));

    final String fileName = "HardwareReport.html";
    JButton bWrite = new JButton("Save " + fileName + "...");
    bWrite.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog((Frame)null, "Save " + fileName, FileDialog.SAVE);
            fd.setFile(fileName);
            fd.setVisible(true);
            if (fd.getFile() == null)
                return;

            try {
                File file = new File(new File(fd.getDirectory()), fd.getFile());
                file.getParentFile().mkdirs();
                Writer w = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
                w.write(html);
                w.close();

                Platform.show(file);
            } catch (Throwable ex) {
                SetupUtils.exception(ex);
            }
        }

    });

    ret.add("South", bWrite);
    return ret;
}
 
開發者ID:adnanmitf09,項目名稱:Rubus,代碼行數:41,代碼來源:HardwareReport.java

示例14: FlickrSettingsPanel

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public FlickrSettingsPanel()
{
	apiKey = new JTextField();
	apiSharedSecret = new JTextField();

	// Yuck, this seems to be the minimal amount of code to get a clickable
	// and styled link
	// (copied from the Cron link in the scheduler)
	JEditorPane apiKeyHelp = new JEditorPane();
	apiKeyHelp.setEditorKit(new HTMLEditorKit());
	apiKeyHelp.setDocument(new HTMLDocument());
	apiKeyHelp.setEditable(false);
	apiKeyHelp.setText("<html><head><style>" + "<!--a{color:#0000cc;text-decoration: none;}//--></style></head>"
		+ "<body>" + getString("settings.label.apikeyhelp"));
	apiKeyHelp.addHyperlinkListener(new HyperlinkListener()
	{
		@Override
		public void hyperlinkUpdate(HyperlinkEvent e)
		{
			if( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
			{
				getClientService().showDocument(e.getURL(), null);
			}
		}
	});
	apiKeyHelp.setBackground(new JPanel().getBackground());

	add(apiKeyHelp, "span 2");

	add(new JLabel(getString("settings.label.apikey")));
	add(apiKey);
	add(new JLabel(getString("settings.label.apisharedsecret")));
	add(apiSharedSecret);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:FlickrSettingsPanel.java

示例15: getPane

import javax.swing.JEditorPane; //導入方法依賴的package包/類
protected JEditorPane getPane(String text) throws Exception {
    if (!SwingUtilities.isEventDispatchThread()) {
        fail("You must run this test from the event dispatch thread! To do that, add @Override protected boolean runInEQ() { return true } from your testcase!");
    }
    String BEGIN = "$start$"; // NOI18N
    String END = "$end$"; // NOI18N
    int sourceStartPos = text.indexOf(BEGIN);
    int caretPos = -1;
    int sourceEndPos = -1;
    if (sourceStartPos != -1) {
        text = text.substring(0, sourceStartPos) + text.substring(sourceStartPos+BEGIN.length());
        sourceEndPos = text.indexOf(END);
        assertTrue(sourceEndPos != -1);
        text = text.substring(0, sourceEndPos) + text.substring(sourceEndPos+END.length());
    } else {
        caretPos = text.indexOf('^');
        if (caretPos != -1) {
            text = text.substring(0, caretPos) + text.substring(caretPos+1);
        }
    }

    JEditorPane pane = new JEditorPane();
    pane.setContentType(getPreferredMimeType());
    final NbEditorKit kit = ((NbEditorKit)getEditorKit(getPreferredMimeType()));


    Thread preload = new Thread(new Runnable() {

        @Override
        public void run() {
            // Preload actions and other stuff
            if (kit instanceof Callable) {
                try {
                    ((Callable) kit).call();
                } catch (Exception ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
            kit.getActions();
        }
    });
    preload.start();
    preload.join();
    pane.setEditorKit(kit);
    pane.setText(text);

    BaseDocument bdoc = (BaseDocument)pane.getDocument();

    bdoc.putProperty(org.netbeans.api.lexer.Language.class, getPreferredLanguage().getLexerLanguage());
    bdoc.putProperty("mimeType", getPreferredMimeType());

    //bdoc.insertString(0, text, null);
    if (sourceStartPos != -1) {
        assertTrue(sourceEndPos != -1);
        pane.setSelectionStart(sourceStartPos);
        pane.setSelectionEnd(sourceEndPos);
    } else if (caretPos != -1) {
        pane.getCaret().setDot(caretPos);
    }
    pane.getCaret().setSelectionVisible(true);

    return pane;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:64,代碼來源:CslTestBase.java


注:本文中的javax.swing.JEditorPane.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。