当前位置: 首页>>代码示例>>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;未经允许,请勿转载。