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


Java StyledEditorKit.getInputAttributes方法代碼示例

本文整理匯總了Java中javax.swing.text.StyledEditorKit.getInputAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java StyledEditorKit.getInputAttributes方法的具體用法?Java StyledEditorKit.getInputAttributes怎麽用?Java StyledEditorKit.getInputAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.StyledEditorKit的用法示例。


在下文中一共展示了StyledEditorKit.getInputAttributes方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: actionPerformed

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent e){
	JEditorPane editor = getEditor(e);
	if (editor != null) {
		StyledEditorKit kit = getStyledEditorKit(editor);
		MutableAttributeSet attr = kit.getInputAttributes();
		boolean strike = (StyleConstants.isStrikeThrough(attr)) ? false : true;
		SimpleAttributeSet sas = new SimpleAttributeSet();
		StyleConstants.setStrikeThrough(sas, strike);
		setCharacterAttributes(editor, sas, false);
	}
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:12,代碼來源:HTMLEditor.java

示例3: highlight

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void highlight(ActionEvent e){
	JEditorPane editor = getEditor(e);
	if(editor != null){
		StyledEditorKit kit = getStyledEditorKit(editor);
		MutableAttributeSet attr = kit.getInputAttributes();
		javax.swing.text.DefaultHighlighter.DefaultHighlightPainter highlightPainter =
                   new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);
		try {
			last = editor.getHighlighter().addHighlight(editor.getSelectionStart(), editor.getSelectionEnd(), highlightPainter);
		} catch (BadLocationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:16,代碼來源:HTMLEditor.java

示例4: action

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void action()
{
	JEditorPane ed = getEditor();
	if(ed != null)
	{
		StyledEditorKit k = getStyledEditorKit(ed);
		MutableAttributeSet as = k.getInputAttributes();
		
		boolean on = StyleConstants.isItalic(as);
		
		SimpleAttributeSet a = new SimpleAttributeSet();
		StyleConstants.setItalic(a, !on);
		setCharacterAttributes(ed, a, false);
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:16,代碼來源:CEditorItalicAction.java

示例5: action

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void action()
{
	JEditorPane ed = getEditor();
	if(ed != null)
	{
		StyledEditorKit k = getStyledEditorKit(ed);
		MutableAttributeSet as = k.getInputAttributes();
		
		boolean on = StyleConstants.isStrikeThrough(as);
		
		SimpleAttributeSet a = new SimpleAttributeSet();
		StyleConstants.setStrikeThrough(a, !on);
		setCharacterAttributes(ed, a, false);
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:16,代碼來源:CEditorStrikethroughAction.java

示例6: action

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void action()
{
	JEditorPane ed = getEditor();
	if(ed != null)
	{
		StyledEditorKit k = getStyledEditorKit(ed);
		MutableAttributeSet as = k.getInputAttributes();
		
		boolean on = StyleConstants.isSubscript(as);
		
		SimpleAttributeSet a = new SimpleAttributeSet();
		StyleConstants.setSubscript(a, !on);
		setCharacterAttributes(ed, a, false);
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:16,代碼來源:CEditorSubscriptAction.java

示例7: action

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void action()
{
	JEditorPane ed = getEditor();
	if(ed != null)
	{
		StyledEditorKit k = getStyledEditorKit(ed);
		MutableAttributeSet as = k.getInputAttributes();
		
		boolean on = StyleConstants.isUnderline(as);
		
		SimpleAttributeSet a = new SimpleAttributeSet();
		StyleConstants.setUnderline(a, !on);
		setCharacterAttributes(ed, a, false);
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:16,代碼來源:CEditorUnderlineAction.java

示例8: action

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
public void action()
{
	JEditorPane ed = getEditor();
	if(ed != null)
	{
		StyledEditorKit k = getStyledEditorKit(ed);
		MutableAttributeSet as = k.getInputAttributes();
		
		boolean on = StyleConstants.isSuperscript(as);
		
		SimpleAttributeSet a = new SimpleAttributeSet();
		StyleConstants.setSuperscript(a, !on);
		setCharacterAttributes(ed, a, false);
	}
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:16,代碼來源:CEditorSuperscriptAction.java

示例9: setCharacterAttributes

import javax.swing.text.StyledEditorKit; //導入方法依賴的package包/類
protected void setCharacterAttributes(JEditorPane ed, AttributeSet as, boolean replace)
{
	int start = ed.getSelectionStart();
	int end = ed.getSelectionEnd();
	
	// word selection logic a-la MS Word
	if(start == end)
	{
		int ws = getWordStart(ed, start);
		if(ws >= 0)
		{
			int we = getWordEnd(ed, end);
			if(we >= 0)
			{
				start = ws;
				end = we;
			}
		}
	}
	
	if(start != end)
	{
		getStyledDocument(ed).setCharacterAttributes(start, end - start, as, replace);
	}
	
	StyledEditorKit k = getStyledEditorKit(ed);
	MutableAttributeSet a = k.getInputAttributes();
	if(replace)
	{
		a.removeAttributes(a);
	}
	a.addAttributes(as);
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:34,代碼來源:CEditorAction.java


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