本文整理了Java中javax.swing.JTextPane.replaceSelection()
方法的一些代码示例,展示了JTextPane.replaceSelection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.replaceSelection()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:replaceSelection
暂无
代码示例来源:origin: groovy/groovy-core
public void replaceSelection(String text) {
// Implement overtype mode by selecting the character at the current
// caret position
if (isOvertypeMode()) {
int pos = getCaretPosition();
if (getSelectedText() == null && pos < getDocument().getLength()) {
moveCaretPosition(pos + 1);
}
}
super.replaceSelection(text);
}
代码示例来源:origin: stackoverflow.com
tp.setCaretPosition(len);
tp.setCharacterAttributes(aset, false);
tp.replaceSelection(msg);
代码示例来源:origin: cmu-phil/tetrad
public void actionPerformed(ActionEvent actionEvent) {
String token = (String) expressionsBox.getSelectedItem();
String signature;
if ("-New Parameter-".equals(token)) {
signature = nextParameterName("b");
} else {
signature = expressionsMap.get(token);
}
while (signature.contains("%")) {
signature = signature.replaceFirst("%", nextParameterName("b"));
}
expressionTextPane.replaceSelection(signature);
}
});
代码示例来源:origin: cmu-phil/tetrad
public void actionPerformed(ActionEvent actionEvent) {
String token = (String) expressionsBox.getSelectedItem();
String signature;
if ("-New Parameter-" .equals(token)) {
signature = nextParameterName("b");
}
else {
signature = expressionsMap.get(token);
}
while (signature.contains("%")) {
signature = signature.replaceFirst("%", nextParameterName("b"));
}
expressionTextPane.replaceSelection(signature);
}
});
代码示例来源:origin: cmu-phil/tetrad
public void actionPerformed(ActionEvent actionEvent) {
String token = (String) expressionsBox.getSelectedItem();
String signature;
if ("-New Parameter-" .equals(token)) {
signature = nextParameterName("b");
}
else {
signature = expressionsMap.get(token);
}
while (signature.contains("%")) {
signature = signature.replaceFirst("%", nextParameterName("b"));
}
expressionTextPane.replaceSelection(signature);
}
});
代码示例来源:origin: beanshell/beanshell
private String replaceRange(Object s, int start, int end) {
String st = s.toString();
text.select(start, end);
text.replaceSelection(st);
//text.repaint();
return st;
}
代码示例来源:origin: beanshell/beanshell
private void append(String string) {
int slen = textLength();
text.select(slen, slen);
text.replaceSelection(string);
}
代码示例来源:origin: jdmp/java-data-mining-package
public void appendError(String s) {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground,
Color.RED);
textField.setCharacterAttributes(aset, false);
textField.replaceSelection(s);
int len = doc.getLength();
textField.setCaretPosition(len);
}
代码示例来源:origin: stackoverflow.com
private void appendToPane(JTextPane tp, String msg, Color c)
{
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);
int len = tp.getDocument().getLength();
tp.setCaretPosition(len);
tp.setCharacterAttributes(aset, false);
tp.replaceSelection(msg);
}
代码示例来源:origin: senbox-org/snap-desktop
private void append(String text, AttributeSet attributes) {
if (this.isVisible()) {
int len = textArea.getDocument().getLength();
textArea.setCaretPosition(len);
textArea.setCharacterAttributes(attributes, false);
textArea.replaceSelection("\n" + text);
textArea.repaint();
} else {
buffer.append(text);
}
}
}
代码示例来源:origin: jdmp/java-data-mining-package
public void appendText(String s) {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground,
Color.BLACK);
textField.setCharacterAttributes(aset, false);
textField.replaceSelection(s);
int len = doc.getLength();
textField.setCaretPosition(len);
}
代码示例来源:origin: org.codehaus.groovy/groovy-console
public void replaceSelection(String text) {
// Implement overtype mode by selecting the character at the current
// caret position
if (isOvertypeMode()) {
int pos = getCaretPosition();
if (getSelectedText() == null && pos < getDocument().getLength()) {
moveCaretPosition(pos + 1);
}
}
super.replaceSelection(text);
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public void replaceSelection(String text) {
// Implement overtype mode by selecting the character at the current
// caret position
if (isOvertypeMode()) {
int pos = getCaretPosition();
if (getSelectedText() == null && pos < getDocument().getLength()) {
moveCaretPosition(pos + 1);
}
}
super.replaceSelection(text);
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
public void replaceSelection(String text) {
// Implement overtype mode by selecting the character at the current
// caret position
if (isOvertypeMode()) {
int pos = getCaretPosition();
if (getSelectedText() == null && pos < getDocument().getLength()) {
moveCaretPosition(pos + 1);
}
}
super.replaceSelection(text);
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public void replaceSelection(String text) {
// Implement overtype mode by selecting the character at the current
// caret position
if (isOvertypeMode()) {
int pos = getCaretPosition();
if (getSelectedText() == null && pos < getDocument().getLength()) {
moveCaretPosition(pos + 1);
}
}
super.replaceSelection(text);
}
代码示例来源:origin: org.kohsuke.droovy/groovy
public void replaceSelection(String text) {
// Implement overtype mode by selecting the character at the current
// caret position
if (isOvertypeMode()) {
int pos = getCaretPosition();
if (getSelectedText() == null && pos < getDocument().getLength()) {
moveCaretPosition(pos + 1);
}
}
super.replaceSelection(text);
}
代码示例来源:origin: T145/JTerm
private void print(String s, TextColor c) {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet color = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c.getColor());
int len = textPane.getDocument().getLength();
textPane.setCaretPosition(len);
textPane.setCharacterAttributes(color, false);
textPane.replaceSelection(s);
}
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
private void appendToPane(JTextPane tp, String msg, Color c) {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);
int len = tp.getDocument().getLength();
tp.setCaretPosition(len);
tp.setCharacterAttributes(aset, false);
tp.replaceSelection(msg);
}
代码示例来源:origin: org.vesalainen.dsql/dsql
@Override
public void replace(String newText, int start, int end)
{
setOff();
int save = sqlPane.getCaretPosition();
sqlPane.setCaretPosition(start);
sqlPane.moveCaretPosition(end);
sqlPane.replaceSelection(newText);
sqlPane.setCaretPosition(save);
setOn();
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu
public ShSh(FileWriter _log)
{
tubeSortieFenetre = new SwingTextDocumentWriter(getDocument(), _log);
tubeClavier = new MinReader();
addCaretListener(new DuCurseur());
addKeyListener(new DuClavier());
getDocument().addDocumentListener(new DuDocument());
attrs = new SimpleAttributeSet();
attrs.addAttribute(this, "pas mal !");
super.replaceSelection("\n");
}
内容来源于网络,如有侵权,请联系作者删除!