本文整理了Java中javax.swing.JEditorPane.getEditorKit()
方法的一些代码示例,展示了JEditorPane.getEditorKit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getEditorKit()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getEditorKit
暂无
代码示例来源:origin: net.java.abeille/abeille
/**
* Fetches the EditorKit for the UI.
*
* @return the component capabilities
*/
public EditorKit getEditorKit(JTextComponent c) {
JEditorPane pane = (JEditorPane) component;
return pane.getEditorKit();
}
代码示例来源:origin: de.sciss/syntaxpane
/**
* Return the DefaultSyntaxKit of this target, or null if the target does not
* have a DefaultSyntaxKit
*
* @return kit or null
*/
public static DefaultSyntaxKit getSyntaxKit(JTextComponent target) {
DefaultSyntaxKit kit = null;
if (target instanceof JEditorPane) {
JEditorPane jEditorPane = (JEditorPane) target;
EditorKit k = jEditorPane.getEditorKit();
if (k instanceof DefaultSyntaxKit) {
kit = (DefaultSyntaxKit) k;
}
}
return kit;
}
代码示例来源:origin: de.sciss/jsyntaxpane
/**
* Return the DefaultSyntaxKit of this target, or null if the target does not
* have a DefaultSyntaxKit
* @param target
* @return kit or null
*/
public static DefaultSyntaxKit getSyntaxKit(JTextComponent target) {
DefaultSyntaxKit kit = null;
if (target instanceof JEditorPane) {
JEditorPane jEditorPane = (JEditorPane) target;
EditorKit k = jEditorPane.getEditorKit();
if (k instanceof DefaultSyntaxKit) {
kit = (DefaultSyntaxKit) k;
}
}
return kit;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Fetches the EditorKit for the UI.
*
* @return the component capabilities
*/
public EditorKit getEditorKit(JTextComponent c) {
JEditorPane pane = (JEditorPane)getComponent();
return (pane==null) ? null : pane.getEditorKit();
}
代码示例来源:origin: UISpec4J/UISpec4J
private static boolean accept(JTextComponent jTextComponent) {
if (!JEditorPane.class.isInstance(jTextComponent)) {
return false;
}
JEditorPane editorPane = (JEditorPane)jTextComponent;
return editorPane.getEditorKit().getContentType().startsWith("text/html");
}
代码示例来源:origin: RPTools/maptool
public void run() {
textPane.setText("<html><body id=\"body\"></body></html>");
((MessagePanelEditorKit) textPane.getEditorKit()).flush();
}
});
代码示例来源:origin: stackoverflow.com
JEditorPane pane = new JEditorPane();
String u = "C:/path/to/bullet.png";
HTMLEditorKit htmlEditorKit = (HTMLEditorKit) pane.getEditorKit();
StyleSheet styleSheet = htmlEditorKit.getStyleSheet();
styleSheet.addRule(String.format("ul{list-style-image:url(%s);margin:0px 20px;", u));
代码示例来源:origin: eu.mihosoft.vrl/vrl
/**
* Inserts a string to the current html document of the specified editor.
* Main usage is to add strings to the current log message.
*
* @param editor message field
* @param html html string to add
* @param location document location where the specified string shall be
* added
*/
private void insertHTML(JEditorPane editor, String html, int location) {
//assumes editor is already set to "text/html" type
HTMLEditorKit kit
= (HTMLEditorKit) editor.getEditorKit();
Document doc = editor.getDocument();
StringReader reader = new StringReader(html);
try {
kit.read(reader, doc, location);
} catch (BadLocationException ex) {
Logger.getLogger(MessageBox.class.getName()).log(
Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(MessageBox.class.getName()).log(
Level.SEVERE, null, ex);
}
}
代码示例来源:origin: stackoverflow.com
JEditorPane ed = new JEditorPane();
ed.setContentType("text/html");
HTMLEditorKit kit = (HTMLEditorKit) ed.getEditorKit();
HTMLDocument doc = (HTMLDocument) ed.getDocument();
doc.setBase(new URL("http://fakeurl.com"));
kit.setAutoFormSubmission(false);
ed.setText("<html>"
+ "<head>"
+ "</head>"
+ "<body>"
+ " <form action='http://fakeurl.com:1'><input type='submit' value='hello 1' /></form>"
+ " <form action='http://fakeurl.com:2'><input type='submit' value='hello 2' /></form>"
+ "</body>");
ed.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
System.err.println(e.getURL().getPort());
}
});
UIManager.setLookAndFeel(NimbusLookAndFeel.class.getName());
JFrame f = new JFrame("test frame");
f.setContentPane(ed);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(1024, 768);
f.setVisible(true);
代码示例来源:origin: de.sciss/jsyntaxpane
/**
* Creates new form ShowAbbsDialog
* @param parent
* @param abbs
*/
public ShowAbbsDialog(JEditorPane parent, Map<String, String> abbs) {
super(SwingUtilities.getWindowAncestor(parent), ModalityType.APPLICATION_MODAL);
initComponents();
Object[] abbsList = abbs.keySet().toArray();
Arrays.sort(abbsList);
jLstAbbs.setListData(abbsList);
this.abbs = abbs;
jEdtAbbr.setEditorKit(parent.getEditorKit());
jLstAbbs.setSelectedIndex(0);
SwingUtils.addEscapeListener(this);
setVisible(true);
}
代码示例来源:origin: de.sciss/syntaxpane
/**
* Creates new form ShowAbbsDialog
* @param parent
* @param abbs
*/
public ShowAbbsDialog(JEditorPane parent, Map<String, String> abbs) {
super(SwingUtilities.getWindowAncestor(parent), ModalityType.APPLICATION_MODAL);
initComponents();
Object[] abbsList = abbs.keySet().toArray();
Arrays.sort(abbsList);
jLstAbbs.setListData(abbsList);
this.abbs = abbs;
jEdtAbbr.setEditorKit(parent.getEditorKit());
jLstAbbs.setSelectedIndex(0);
SwingUtils.addEscapeListener(this);
setVisible(true);
}
代码示例来源:origin: de.sciss/jsyntaxpane
@Override
public void actionPerformed(ActionEvent e) {
JTextComponent target = getTextComponent(e);
if (target instanceof JEditorPane) {
JEditorPane jEditorPane = (JEditorPane) target;
DefaultSyntaxKit kit = (DefaultSyntaxKit) jEditorPane.getEditorKit();
boolean status = kit.toggleComponent(jEditorPane, componentName);
putValue(SELECTED_KEY, status);
}
}
}
代码示例来源:origin: de.sciss/syntaxpane
@Override
public void actionPerformed(ActionEvent e) {
JTextComponent target = getTextComponent(e);
if (target instanceof JEditorPane) {
JEditorPane jEditorPane = (JEditorPane) target;
DefaultSyntaxKit kit = (DefaultSyntaxKit) jEditorPane.getEditorKit();
boolean status = kit.toggleComponent(jEditorPane, componentName);
putValue(SELECTED_KEY, status);
}
}
}
代码示例来源:origin: JetBrains/jediterm
private void updateStyle(@NotNull JEditorPane pane) {
EditorKit kit = pane.getEditorKit();
if (kit instanceof HTMLEditorKit) {
StyleSheet css = ((HTMLEditorKit)kit).getStyleSheet();
css.addRule("body, p {" +
"color:#" + ColorUtil.toHex(getForeground()) + ";" +
"font-family:" + getFont().getFamily() + ";" +
"font-size:" + getFont().getSize() + "pt;" +
"white-space:nowrap;}");
}
}
}
代码示例来源:origin: de.sciss/jsyntaxpane
private void jCmbLangsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCmbLangsItemStateChanged
if (evt.getStateChange() == ItemEvent.SELECTED) {
String lang = jCmbLangs.getSelectedItem().toString();
// save the state of the current JEditorPane, as it's Document is about
// to be replaced.
String oldText = jEdtTest.getText();
// install a new DefaultSyntaxKit on the JEditorPane for the requested language.
jEdtTest.setContentType(lang);
// Recreate the Toolbar
jToolBar1.removeAll();
EditorKit kit = jEdtTest.getEditorKit();
if (kit instanceof DefaultSyntaxKit) {
DefaultSyntaxKit defaultSyntaxKit = (DefaultSyntaxKit) kit;
defaultSyntaxKit.addToolBarActions(jEdtTest, jToolBar1);
}
jToolBar1.validate();
try {
// setText should not be called (read the JavaDocs). Better use the read
// method and create a new document.
jEdtTest.read(new StringReader(oldText), lang);
} catch (IOException ex) {
Logger.getLogger(SyntaxTester.class.getName()).log(Level.SEVERE, null, ex);
}
}
jEdtTest.requestFocusInWindow();
}//GEN-LAST:event_jCmbLangsItemStateChanged
代码示例来源: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: 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: org.netbeans.modules/org-netbeans-modules-visualweb-extension-openide
TextTransferable(JTextComponent c, int start, int end) {
this.c = c;
Document doc = c.getDocument();
try {
p0 = doc.createPosition(start);
p1 = doc.createPosition(end);
plainData = c.getSelectedText();
if (c instanceof JEditorPane) {
JEditorPane ep = (JEditorPane)c;
mimeType = ep.getContentType();
if (mimeType.startsWith("text/plain")) {
return;
}
StringWriter sw = new StringWriter(p1.getOffset() - p0.getOffset());
ep.getEditorKit().write(sw, doc, p0.getOffset(), p1.getOffset() - p0.getOffset());
if (mimeType.startsWith("text/html")) {
htmlData = sw.toString();
} else {
richText = sw.toString();
}
}
} catch (BadLocationException ble) {
} catch (IOException ioe) {
}
}
代码示例来源: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: Jamling/SmartIM
@Override
public void run() {
try {
HTMLEditorKit kit = (HTMLEditorKit) historyWidget
.getEditorKit();
HTMLDocument doc = (HTMLDocument) historyWidget
.getDocument();
// historyWidget.getDocument().insertString(len - offset,
// trimMsg(msg), null);
// Element root = doc.getDefaultRootElement();
// Element body = root.getElement(1);
// doc.insertBeforeEnd(body, msg);
int pos = historyWidget.getCaretPosition();
kit.insertHTML(doc, doc.getLength(), msg, 0, 0, null);
historyWidget.setCaretPosition(
scrollLock ? pos : doc.getLength());
} catch (Exception e) {
e.printStackTrace();
}
}
});
内容来源于网络,如有侵权,请联系作者删除!