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


Java StyledEditorKit類代碼示例

本文整理匯總了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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:17,代碼來源:HTMLEditor.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:17,代碼來源:HTMLEditor.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:17,代碼來源:HTMLEditor.java

示例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);
		}
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:24,代碼來源:CEditorBoldAction.java

示例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);
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:17,代碼來源:InfoField.java

示例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;
}
 
開發者ID:iamxiatian,項目名稱:wikit,代碼行數:24,代碼來源:About.java

示例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());
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:22,代碼來源:HTMLEditor.java

示例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) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:JEditorPane.java

示例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));
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:19,代碼來源:HTMLEditorKitTest.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:15,代碼來源:HTMLEditor.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:15,代碼來源:HTMLEditor.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:16,代碼來源:HTMLEditor.java

示例13: removeNotify

import javax.swing.text.StyledEditorKit; //導入依賴的package包/類
@Override
public void removeNotify () {
    setEditorKit (new StyledEditorKit ());
    if (hyperlinkListener != null) {
        removeHyperlinkListener (hyperlinkListener);
    }
    scrollPane = null;
    super.removeNotify ();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:DetailsPanel.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Dresden,代碼行數:15,代碼來源:HTMLEditor.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Dresden,代碼行數:15,代碼來源:HTMLEditor.java


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