本文整理了Java中javax.swing.JEditorPane.setDocument()
方法的一些代码示例,展示了JEditorPane.setDocument()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.setDocument()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:setDocument
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private void buildContentPanel() {
editorPane = new JEditorPane ();
editorPane.setContentType("text/rtf");
editorPane.addKeyListener(new InputListener());
// defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
StyleConstants.setFontFamily(defaultAttrSet, "Lucida Sans");
Document doc = new DefaultStyledDocument();
editorPane.setDocument(doc);
try {
doc.insertString(0, initText, defaultAttrSet);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
JScrollPane scrollPane = new JScrollPane(editorPane);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
editorPane.setEditable(true);
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void buildContentPanel() {
editorPane = new JEditorPane ();
editorPane.setContentType("text/rtf");
editorPane.addKeyListener(new InputListener());
// defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans");
Document doc = new DefaultStyledDocument();
editorPane.setDocument(doc);
try {
doc.insertString(0, initText, defaultAttrSet);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
JScrollPane scrollPane = new JScrollPane(editorPane);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
editorPane.setEditable(true);
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void clearDocument() {
editorPane.setContentType("text/rtf");
Document doc = new DefaultStyledDocument();
editorPane.setDocument(doc);
// defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
// StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans Unicode");
log.info("attr: "+defaultAttrSet);
try {
doc.insertString(0, " ", defaultAttrSet);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
editorPane.setEditable(true);
editorPane.revalidate();
editorPane.repaint();
saveUntagged.setEnabled(false);
saveTaggedAs.setEnabled(false);
taggedContents = null;
htmlContents = null;
loadedFile = null;
}
代码示例来源:origin: stanfordnlp/CoreNLP
public void clearDocument() {
editorPane.setContentType("text/rtf");
Document doc = new DefaultStyledDocument();
editorPane.setDocument(doc);
// defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
// StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans Unicode");
log.info("attr: "+defaultAttrSet);
try {
doc.insertString(0, " ", defaultAttrSet);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
editorPane.setEditable(true);
editorPane.revalidate();
editorPane.repaint();
saveUntagged.setEnabled(false);
saveTaggedAs.setEnabled(false);
taggedContents = null;
untaggedContents = null;
htmlContents = null;
loadedFile = null;
}
代码示例来源:origin: igniterealtime/Spark
private void setDocument(String type, Document document) {
setContentType(type);
JEditorPane.setDocument(document);
}
代码示例来源:origin: markiewb/nb-codeoutline
@Override
public void setDocument(Document doc)
{
super.setDocument(doc);
setBorder(null);
fakeRepaint();
}
代码示例来源:origin: stackoverflow.com
String htmlString = "<body><h1>Karaoke Beyonce song</h1><p><span class="highlight">Hello</span>world</p></body>";
JEditorPane pane = new JEditorPane();
HTMLEditorKit kit = new HTMLEditorKit();
pane.setEditable(false);
pane.setEditorKit(kit);
StyleSheet sh = editorKit.getStyleSheet();
sh.addRule("span.highlight {background-color:yellow}");
Document doc = kit.createDefaultDocument();
pane.setDocument(doc);
pane.setText(htmlString);
代码示例来源:origin: markiewb/nb-codeoutline
/**
* Set the document displayed in this NaviView.
* @param document the document to be displayed - cannot be null.
*/
public void setDocument(Document document)
{
scrollBar.removeAdjustmentListener(this);
this.document = document;
editorPane.setDocument(document);
scrollBar.addAdjustmentListener(this);
documentChangedLength();
}
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
@Override public void setDocument(Document doc) {
Document document = getDocument();
if (document != null && _listener != null) {
document.removeDocumentListener(_listener);
}
super.setDocument(doc);
if (doc != null) {
if (_listener == null) {
_listener = new ResizingDocumentListener();
}
doc.addDocumentListener(_listener);
}
updateSize();
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void run() {
// #23486: pane could not be initialized yet.
if(pane != null) {
Document doc = support.createStyledDocument(
pane.getEditorKit());
pane.setDocument (doc);
pane.setEditorKit (null);
}
removeAll();
initialized = false;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
doc.insertString(0, selectedText, null);
selectedTextPane.setEditorKit(kit);
selectedTextPane.setDocument(doc);
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void run() {
// #23486: pane could not be initialized yet.
if(pane != null) {
Document doc = support.createStyledDocument(
pane.getEditorKit());
pane.setDocument (doc);
pane.setEditorKit (null);
}
removeAll();
initialized = false;
}
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
ss.addRule("a, a:HOVER, a:VISITED, a:ACTIVE { color: rgb(" + rgb + "); text-decoration:none; cursor: default;}");
jEditorPane1.setDocument(editorKit.createDefaultDocument());
jEditorPane1.setText("<html>\n" +
" <head>\n" +
代码示例来源:origin: com.darwinsys/darwinsys-api
public void run() {
// System.out.println("PageLoader: u=" + url);
if (url == null) {
// restore the original cursor
help.setCursor(cursor);
// PENDING(prinz) remove this hack when
// automatic validation is activated.
Container parent = help.getParent();
parent.repaint();
} else {
Document doc = help.getDocument();
try {
help.setPage(url);
} catch (Exception ioe) {
help.setDocument(doc);
getToolkit().beep();
} finally {
// schedule the cursor to revert after
// the paint has happended.
url = null;
SwingUtilities.invokeLater(this);
}
}
}
}
代码示例来源:origin: IanDarwin/darwinsys-api
public void run() {
// System.out.println("PageLoader: u=" + url);
if (url == null) {
// restore the original cursor
help.setCursor(cursor);
// PENDING(prinz) remove this hack when
// automatic validation is activated.
Container parent = help.getParent();
parent.repaint();
} else {
Document doc = help.getDocument();
try {
help.setPage(url);
} catch (Exception ioe) {
help.setDocument(doc);
getToolkit().beep();
} finally {
// schedule the cursor to revert after
// the paint has happended.
url = null;
SwingUtilities.invokeLater(this);
}
}
}
}
代码示例来源:origin: org.softsmithy.lib/lib-core
/**
* Configures the wrapped JEditorPane to display the HTML body.
*/
private void configureHtmlText(){
JEditorPane editorPane = (JEditorPane) getComponent();
if (editorPane != null){
editorPane.setDocument(editorPane.getEditorKit().createDefaultDocument());
editorPane.setText(createHtmlText());//text.replaceAll("\n", "<br>"));
HTMLDocument doc=(HTMLDocument)editorPane.getDocument();
doc.setParagraphAttributes(0,doc.getLength(),attributeSet,true);
//System.out.println(createHtmlText()+" -> ");
//System.out.println(editorPane.getText());
}
}
代码示例来源:origin: JChemPaint/jchempaint
} catch (IOException ioe)
html.setDocument(doc);
getToolkit().beep();
} finally
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation
/**
* Initializes document of expanded context pane.
*
* @param doc - document
*/
public void setContextExpansionDocument(Document doc) {
String mimeType = DocumentUtilities.getMimeType(doc);
if (mimeType == null) {
mimeType = MIMENames.CPLUSPLUS_MIME_TYPE;
}
jCodeExpansionEditorPane.setCaretPosition(0);
jCodeExpansionEditorPane.setContentType(mimeType);
jCodeExpansionEditorPane.setDocument(doc);
jCodeExpansionEditorPane.putClientProperty("HelpID","MacroExpansionWindow"); //NOI18N
doc.putProperty(JEditorPane.class, jCodeExpansionEditorPane);
}
代码示例来源:origin: org.netbeans.api/org-openide-text
@Override
public void setDocument(Document doc) {
super.setDocument(doc);
// Setting DelegatingTransferHandler, where CallbackTransferable will
// be handled in importData method.
// For more details, please refer issue #53439
if (doc != null){
TransferHandler thn = getTransferHandler();
if( !(thn instanceof DelegatingTransferHandler) ) {
DelegatingTransferHandler dth = new DelegatingTransferHandler(thn);
setTransferHandler(dth);
}
DropTarget currDt = getDropTarget();
if( !(currDt instanceof DelegatingDropTarget ) ) {
DropTarget dt = new DelegatingDropTarget( currDt );
setDropTarget( dt );
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-editor-fold-nbui
tooltipPane.setDocument(doc);
tooltipPane.setEditable(false);
return new FoldToolTip(editorPane, tooltipPane, getForegroundColor());
内容来源于网络,如有侵权,请联系作者删除!