本文整理了Java中javax.swing.JEditorPane.getEditorKitForContentType()
方法的一些代码示例,展示了JEditorPane.getEditorKitForContentType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getEditorKitForContentType()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getEditorKitForContentType
暂无
代码示例来源:origin: org.netbeans.api/org-openide-awt
@Override
public EditorKit getEditorKitForContentType( String type ) {
if( "text/html".equals( type ) ) {
return new HTMLEditorKit() {
@Override
public Document createDefaultDocument() {
StyleSheet styles = getStyleSheet();
//#200472 - hack to make JDK 1.7 javadoc readable
StyleSheet ss = new FilteredStyleSheet();
ss.addStyleSheet(styles);
HTMLDocument doc = new HTMLDocument(ss);
doc.setParser(getParser());
doc.setAsynchronousLoadPriority(4);
doc.setTokenThreshold(100);
return doc;
}
};
}
return super.getEditorKitForContentType( type );
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu
public EditorKit getEditorKitForContentType(String _type)
{
/*
if(!BuLib.isSwing11())
{
// remove charset if swing 1.03
int i=_type.indexOf(";");
if(i>=0) _type=_type.substring(0,i).trim();
}
*/
return super.getEditorKitForContentType(_type);
}
代码示例来源:origin: javax.help/javahelp
public EditorKit getEditorKitForContentType(String type) {
if (typeHandlers == null) {
typeHandlers = new Hashtable(3);
}
EditorKit k = (EditorKit) typeHandlers.get(type);
if (k == null) {
k = theViewer.createEditorKitForContentType(type);
if (k != null) {
setEditorKitForContentType(type, k);
typeHandlers.put(type, k);
}
}
if (k == null) {
k = super.getEditorKitForContentType(type);
if (k != null) {
typeHandlers.put(type, k);
}
}
return k;
}
代码示例来源:origin: stackoverflow.com
// read rtf from file
JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
EditorKit rtfKit = p.getEditorKitForContentType("text/rtf");
rtfKit.read(new FileReader(fileName), p.getDocument(), 0);
rtfKit = null;
// convert to text
EditorKit txtKit = p.getEditorKitForContentType("text/plain");
Writer writer = new StringWriter();
txtKit.write(writer, p.getDocument(), 0, p.getDocument().getLength());
String documentText = writer.toString();
代码示例来源:origin: stackoverflow.com
// read rtf from file
JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
EditorKit rtfKit = p.getEditorKitForContentType("text/rtf");
rtfKit.read(new FileReader(fileName), p.getDocument(), 0);
rtfKit = null;
// convert to text
EditorKit txtKit = p.getEditorKitForContentType("text/plain");
Writer writer = new StringWriter();
txtKit.write(writer, p.getDocument(), 0, p.getDocument().getLength());
String documentText = writer.toString();
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-bugtracking
private FindSupport(TopComponent tc) {
this.tc = tc;
bar = new FindBar(this);
ActionMap actionMap = tc.getActionMap();
CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class);
actionMap.put(a.getActionMapKey(), new FindAction(true));
actionMap.put(FIND_NEXT_ACTION, new FindAction(true));
actionMap.put(FIND_PREVIOUS_ACTION, new FindAction(false));
// Hack ensuring the same shortcuts as editor
JEditorPane pane = new JEditorPane();
for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N
Object name = action.getValue(Action.NAME);
if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIOUS_ACTION.equals(name)) {
reuseShortcut(action);
}
}
// PENDING the colors below should not be hardcoded
highlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66));
highlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227));
pattern = Pattern.compile("$^"); // NOI18N
}
代码示例来源:origin: stackoverflow.com
JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
EditorKit kitRtf = p.getEditorKitForContentType("text/rtf");
try {
kitRtf.read(rtf, p.getDocument(), 0);
kitRtf = null;
EditorKit kitHtml = p.getEditorKitForContentType("text/html");
Writer writer = new StringWriter();
kitHtml.write(writer, p.getDocument(), 0, p.getDocument().getLength());
代码示例来源:origin: stackoverflow.com
private static String useWebKitToConvertRtfToPlaintext(String rtf) throws IOException {
StringReader rtfReader = new StringReader(rtf);
JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
RTFEditorKit kitRtf = new RTFEditorKit();
try {
kitRtf.read(rtfReader, p.getDocument(), 0);
EditorKit plainKit = p.getEditorKitForContentType("text/plain");
Writer writer = new StringWriter();
plainKit.write(writer, p.getDocument(), 0, p.getDocument().getLength());
String out = writer.toString();
return out;
} catch (BadLocationException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders
return;
javax.swing.text.EditorKit kit = ((javax.swing.JEditorPane) comp).getEditorKitForContentType("text/html"); // NOI18N
if (! (kit instanceof javax.swing.text.html.HTMLEditorKit))
return;
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void actionPerformed(ActionEvent e)
{
if(!(this.isEnabled()))
{
return;
}
JEditorPane editor = getEditor(e);
if(editor != null)
{
String stylename = (String)(parent.getSelectedItem());
if(stylename == null)
{
return;
}
else if(stylename.equals(Translatrix.getTranslationString("NoCSSStyle")))
{
return;
}
boolean replace = false;
MutableAttributeSet attr = null;
SimpleAttributeSet cls = new SimpleAttributeSet();
cls.addAttribute(HTML.Attribute.CLASS, stylename);
attr = new SimpleAttributeSet();
attr.addAttribute(HTML.Tag.FONT, cls);
MutableAttributeSet inattr = ((HTMLEditorKit)(editor.getEditorKitForContentType("text/html"))).getInputAttributes();
inattr.addAttributes(attr);
setCharacterAttributes(editor, attr, replace);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!