本文整理汇总了Java中javax.swing.text.StyledEditorKit类的典型用法代码示例。如果您正苦于以下问题:Java StyledEditorKit类的具体用法?Java StyledEditorKit怎么用?Java StyledEditorKit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StyledEditorKit类属于javax.swing.text包,在下文中一共展示了StyledEditorKit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: boldActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void boldActionB_actionPerformed(ActionEvent e) {
if (!bold) {
boldActionB.setBorder(border2);
} else {
boldActionB.setBorder(border1);
}
bold = !bold;
boldActionB.setBorderPainted(bold);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
*/
// Function to bold when button is clicked
new StyledEditorKit.BoldAction().actionPerformed(e);
}
示例2: italicActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void italicActionB_actionPerformed(ActionEvent e) {
if (!italic) {
italicActionB.setBorder(border2);
} else {
italicActionB.setBorder(border1);
}
italic = !italic;
italicActionB.setBorderPainted(italic);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
*/
// Function to italicize when button is clicked
new StyledEditorKit.ItalicAction().actionPerformed(e);
}
示例3: underActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void underActionB_actionPerformed(ActionEvent e) {
if (!under) {
underActionB.setBorder(border2);
} else {
underActionB.setBorder(border1);
}
under = !under;
underActionB.setBorderPainted(under);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
*/
// Function to underline when button is clicked
new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
示例4: action
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void action()
{
// FIX bold word if no selection! (only if chars on both sides are letters or digits)
// nn|nn -> BB|BB
// nn|. -> nn|.
// <sp>|<sp> -> <sp>|<sp>
// BBB|nnn -> nnn|nnn
JEditorPane ed = getEditor();
if(ed != null)
{
StyledEditorKit k = getStyledEditorKit(ed);
if(k != null)
{
MutableAttributeSet as = k.getInputAttributes();
boolean on = StyleConstants.isBold(as);
SimpleAttributeSet newAttrs = new SimpleAttributeSet();
StyleConstants.setBold(newAttrs, !on);
setCharacterAttributes(ed, newAttrs, false);
}
}
}
示例5: setText
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void setText(String text)
{
if(CKit.startsWithIgnoreCase(text, "<html>"))
{
setEditorKit(new CHtmlEditorKit());
setFont(getFont());
setForeground(getForeground());
}
else
{
setEditorKit(new StyledEditorKit());
}
super.setText(text);
setCaretPosition(0);
}
示例6: createPanel
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public static JPanel createPanel() {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
JTextPane editorPane = new JTextPane();
editorPane.setEditable(false);
//wrap long line
editorPane.setEditorKit(new StyledEditorKit());
editorPane.setContentType("text/html");
try {
URLClassLoader urlLoader = (URLClassLoader)About.class.getClassLoader();
String html = About.class.getPackage().getName().replaceAll("\\.", "/") + "/about.html";
System.out.println(html);
URL url = urlLoader.findResource(html);//可以用html格式文件做你的帮助系统了
editorPane.setPage(url);
} catch (IOException e1) {
editorPane.setText(e1.getMessage());
}
//editorPane.setText("<html><body>个人主页:<a href='xiatian.irm.cn'>http://xiatian.irm.cn/</a></body></html>");
mainPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER);
return mainPanel;
}
示例7: HTMLEditor
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
/** Creates new form HTMLEditor */
public HTMLEditor(EditableResources res, String htmlText) {
initComponents();
this.res = res;
htmlComponent = new com.codename1.ui.html.HTMLComponent();
htmlComponent.setBodyText(htmlText, "UTF-8");
final CodenameOneComponentWrapper wrapper = new CodenameOneComponentWrapper(htmlComponent);
uiPreview.add(java.awt.BorderLayout.CENTER, wrapper);
wysiwyg.setText(htmlText);
source.setText(htmlText);
Listener l = new Listener();
wysiwyg.getDocument().addDocumentListener(l);
source.getDocument().addDocumentListener(l);
JButton b = jToolBar1.add(new StyledEditorKit.BoldAction());
b.setText("<html><body><b>B</b></body></html>");
JButton i = jToolBar1.add(new StyledEditorKit.ItalicAction());
i.setText("<html><body><i>I</i></body></html>");
JButton u = jToolBar1.add(new StyledEditorKit.UnderlineAction());
u.setText("<html><body><u>U</u></body></html>");
jToolBar1.add(new InsertImageAction());
}
示例8: replaceSelection
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
@Override
public synchronized void replaceSelection(final String s) {
if (!isEditable()) {
new DefaultEditorKit.BeepAction().actionPerformed(null);
return;
}
int start = getSelectionStart();
int end = getSelectionEnd();
Document doc = getDocument();
try {
if (start != end) {
doc.remove(start, end - start);
}
//May be these attributes placed in Document ????
AttributeSet as = (editorKit instanceof StyledEditorKit) ? ((StyledEditorKit) editorKit)
.getInputAttributes()
: null;
if (s != null) {
doc.insertString(start, s, as);
}
} catch (BadLocationException e) {
}
}
示例9: testGetActions
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void testGetActions() throws Exception {
Action[] ancestorActions = new StyledEditorKit().getActions();
Action[] actions = editorKit.getActions();
assertEquals(12, actions.length - ancestorActions.length);
Action[] predefinedInsertHTMLTextActions = createPredefinedInsertHTMLTextActions();
for (int i = 0; i < predefinedInsertHTMLTextActions.length; i++) {
Action action = findActionWithName(actions,
predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
if (action != null) {
assertTrue("Action is not same" + action.getValue(Action.NAME),
compareInsertHTMLTextActions(action,
predefinedInsertHTMLTextActions[i]));
} else {
fail("Action not found: " + predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
}
}
}
示例10: boldActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void boldActionB_actionPerformed(ActionEvent e) {
if (!bold) {
boldActionB.setBorder(border2);
} else {
boldActionB.setBorder(border1);
}
bold = !bold;
boldActionB.setBorderPainted(bold);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
*/
new StyledEditorKit.BoldAction().actionPerformed(e);
}
示例11: italicActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void italicActionB_actionPerformed(ActionEvent e) {
if (!italic) {
italicActionB.setBorder(border2);
} else {
italicActionB.setBorder(border1);
}
italic = !italic;
italicActionB.setBorderPainted(italic);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
*/
new StyledEditorKit.ItalicAction().actionPerformed(e);
}
示例12: underActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void underActionB_actionPerformed(ActionEvent e) {
if (!under) {
underActionB.setBorder(border2);
} else {
underActionB.setBorder(border1);
}
under = !under;
underActionB.setBorderPainted(under);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
*/
new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
示例13: removeNotify
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
@Override
public void removeNotify () {
setEditorKit (new StyledEditorKit ());
if (hyperlinkListener != null) {
removeHyperlinkListener (hyperlinkListener);
}
scrollPane = null;
super.removeNotify ();
}
示例14: boldActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void boldActionB_actionPerformed(ActionEvent e) {
if (!bold) {
boldActionB.setBorder(border2);
} else {
boldActionB.setBorder(border1);
}
bold = !bold;
boldActionB.setBorderPainted(bold);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
*/
new StyledEditorKit.BoldAction().actionPerformed(e);
}
示例15: italicActionB_actionPerformed
import javax.swing.text.StyledEditorKit; //导入依赖的package包/类
public void italicActionB_actionPerformed(ActionEvent e) {
if (!italic) {
italicActionB.setBorder(border2);
} else {
italicActionB.setBorder(border1);
}
italic = !italic;
italicActionB.setBorderPainted(italic);
/*
* SimpleAttributeSet attrs = new SimpleAttributeSet();
* attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
*/
new StyledEditorKit.ItalicAction().actionPerformed(e);
}