本文整理了Java中javax.swing.text.StyledDocument.getStyle()
方法的一些代码示例,展示了StyledDocument.getStyle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.getStyle()
方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:getStyle
暂无
代码示例来源:origin: magefree/mage
private void drawText(java.util.List<String> strings) {
text.setText("");
StyledDocument doc = text.getStyledDocument();
try {
for (String line : strings) {
doc.insertString(doc.getLength(), line + '\n', doc.getStyle("regular"));
}
} catch (BadLocationException ble) {
}
text.setCaretPosition(0);
}
代码示例来源:origin: magefree/mage
protected void drawText() {
text.setText("");
StyledDocument doc = text.getStyledDocument();
try {
for (String rule : getRules()) {
doc.insertString(doc.getLength(), rule + '\n', doc.getStyle("small"));
}
} catch (BadLocationException e) {
}
text.setCaretPosition(0);
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* {@inheritDoc}
*/
@Override
public Style getStyle(String nm) {
return ((StyledDocument) delegate).getStyle(nm);
}
代码示例来源:origin: net.sf.jt400/jt400
/**
Returns a named style.
@param name The name of the style.
@return The style.
**/
public synchronized Style getStyle (String name)
{
return document_.getStyle (name);
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* {@inheritDoc}
*/
public Style getStyle(String nm) {
return ((StyledDocument) delegate).getStyle(nm);
}
代码示例来源:origin: tmyroadctfig/swingx
/**
* {@inheritDoc}
*/
@Override
public Style getStyle(String nm) {
return ((StyledDocument) delegate).getStyle(nm);
}
代码示例来源:origin: mucommander/mucommander
/**
* Inserts the specified URL in the specified document.
* @param doc document in which to insert the text.
* @param url url to insert.
* @throws BadLocationException thrown if something wrong happened to the document.
*/
private static void insertUrl(StyledDocument doc, String url) throws BadLocationException {
doc.insertString(doc.getLength(), " ", doc.getStyle(STYLE_NORMAL));
doc.insertString(doc.getLength(), url + LINE_BREAK, doc.getStyle(STYLE_URL));
}
代码示例来源:origin: mucommander/mucommander
/**
* Inserts the specified header in the specified document.
* @param doc document in which to insert the text.
* @param string text to insert.
* @throws BadLocationException thrown if something wrong happened to the document.
*/
private static void insertHeader(StyledDocument doc, String string) throws BadLocationException {
doc.insertString(doc.getLength(), string + LINE_BREAK, doc.getStyle(STYLE_HEADER));
}
代码示例来源:origin: mucommander/mucommander
/**
* Inserts the specified string and details in the specified document.
* @param doc document in which to insert the text.
* @param string text to insert.
* @param details details that will be added to the text.
* @throws BadLocationException thrown if something wrong happened to the document.
*/
private static void insertDetailedString(StyledDocument doc, String string, String details) throws BadLocationException {
doc.insertString(doc.getLength(), string + " ", doc.getStyle(STYLE_NORMAL));
doc.insertString(doc.getLength(), "(" + details + ")" + LINE_BREAK, doc.getStyle(STYLE_DETAILS));
}
代码示例来源:origin: mucommander/mucommander
/**
* Inserts the specified string in the specified document.
* @param doc document in which to insert the text.
* @param string text to insert.
* @throws BadLocationException thrown if something wrong happened to the document.
*/
private static void insertNormalString(StyledDocument doc, String string) throws BadLocationException {
doc.insertString(doc.getLength(), string + LINE_BREAK, doc.getStyle(STYLE_NORMAL));
}
代码示例来源:origin: mucommander/mucommander
/**
* Inserts a line break in the specified document.
* @param doc document in which to insert the text.
* @throws BadLocationException thrown if something wrong happened to the document.
*/
private static void insertLineBreak(StyledDocument doc) throws BadLocationException {
doc.insertString(doc.getLength(), LINE_BREAK, doc.getStyle(STYLE_NORMAL));
}
代码示例来源:origin: com.numdata/numdata-swing
/**
* Redirects the standard output and error streams to the console.
*/
public void redirectStandardStreams()
{
System.setOut( new PrintStream( new ConsoleStream( null ) ) );
System.setErr( new PrintStream( new ConsoleStream( _document.getStyle( "error" ) ) ) );
}
代码示例来源:origin: org.integratedmodelling/klab-common
/**
* This is called when the input color is changed so that all input is added with the
* AttributeSet (Style) that has been specified for input.
*/
private void setInputAttribute() {
inputControl.setInputAttributeSet(consoleStyledDocument.getStyle(inputColor));
if (!useInlineInput) {
inputArea.setForeground(getStyleColorFromCode(inputColor.charAt(0))); // Foreground
inputArea.setBackground(getStyleColorFromCode(inputColor.charAt(1))); // Background
}
}
代码示例来源:origin: bbuck/DragonConsole
/**
* This is called when the input color is changed so that all input is added
* with the AttributeSet (Style) that has been specified for input.
*/
private void setInputAttribute() {
inputControl.setInputAttributeSet(consoleStyledDocument.getStyle(inputColor));
if (!useInlineInput) {
inputArea.setForeground(getStyleColorFromCode(inputColor.charAt(0))); // Foreground
inputArea.setBackground(getStyleColorFromCode(inputColor.charAt(1))); // Background
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2
private void insert(String text, LineStyle style) {
assert ! Log.Dis.cndAsm;
try {
styledDoc.insertString(styledDoc.getLength(),
text,
styledDoc.getStyle(style.toString()));
} catch (BadLocationException ble2) {
System.err.println("View.clear(): Couldn't insert initial text into document.");
}
}
代码示例来源:origin: Vhati/Slipstream-Mod-Manager
public void appendLinkText( String linkURL, String linkTitle ) throws BadLocationException {
if ( browseWorks && linkURL.matches( "^(?:https?|ftp)://.*" ) ) {
SimpleAttributeSet tmpAttr = new SimpleAttributeSet( doc.getStyle( STYLE_HYPERLINK ) );
tmpAttr.addAttribute( ATTR_HYPERLINK_TARGET, linkURL );
doc.insertString( doc.getLength(), linkTitle, tmpAttr );
} else {
doc.insertString( doc.getLength(), linkURL, doc.getStyle( STYLE_REGULAR ) );
}
}
代码示例来源:origin: protegeproject/protege
private static Style getStyleAtPoint(JTextPane text, Point point) {
int pos = text.viewToModel(point);
StyledDocument doc = text.getStyledDocument();
Element element = doc.getCharacterElement(pos);
AttributeSet addtributes = element.getAttributes();
return doc.getStyle((String) addtributes
.getAttribute(StyleConstants.NameAttribute));
}
代码示例来源:origin: protegeproject/protege
@Override
public void mouseMoved(MouseEvent e) {
int pos = previewText.viewToModel(e.getPoint());
StyledDocument doc = previewText.getStyledDocument();
Element element = doc.getCharacterElement(pos);
AttributeSet addtributes = element.getAttributes();
Style style = doc.getStyle((String) addtributes
.getAttribute(StyleConstants.NameAttribute));
previewText.setToolTipText(
"Click to change the " + style.getName() + " color");
}
});
代码示例来源:origin: SINTEF-9012/JArduino
public static void print(String id, String data){
try {
StyledDocument doc = screen.getStyledDocument();
doc.insertString(doc.getLength(), formatForPrint(data), doc.getStyle("receive"+id+"Style"));
screen.setCaretPosition(doc.getLength());
} catch (BadLocationException ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: SINTEF-9012/JArduino
public static void print(String id, String data){
try {
StyledDocument doc = screen.getStyledDocument();
doc.insertString(doc.getLength(), formatForPrint(data), doc.getStyle("receive"+id+"Style"));
screen.setCaretPosition(doc.getLength());
} catch (BadLocationException ex) {
ex.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!