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); }
tp.setCaretPosition(len); tp.setCharacterAttributes(aset, false); tp.replaceSelection(msg);
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); } });
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); } });
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); } });
private String replaceRange(Object s, int start, int end) { String st = s.toString(); text.select(start, end); text.replaceSelection(st); //text.repaint(); return st; }
private void append(String string) { int slen = textLength(); text.select(slen, slen); text.replaceSelection(string); }
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); }
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); }
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); } } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
@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(); }
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"); }