use of javax.swing.text.DefaultCaret in project java-swing-tips by aterai.
the class HighlightCursorTextArea method updateUI.
@Override
public void updateUI() {
super.updateUI();
setOpaque(false);
Caret caret = new DefaultCaret() {
// [UnsynchronizedOverridesSynchronized]
// Unsynchronized method damage overrides synchronized method in DefaultCaret
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
@Override
protected synchronized void damage(Rectangle r) {
if (Objects.nonNull(r)) {
JTextComponent c = getComponent();
x = 0;
y = r.y;
width = c.getSize().width;
height = r.height;
c.repaint();
}
}
};
// caret.setBlinkRate(getCaret().getBlinkRate());
caret.setBlinkRate(UIManager.getInt("TextArea.caretBlinkRate"));
setCaret(caret);
}
use of javax.swing.text.DefaultCaret in project java-swing-tips by aterai.
the class HighlightCursorTextArea method paintComponent.
@Override
protected void paintComponent(Graphics g) {
Caret c = getCaret();
if (c instanceof DefaultCaret) {
Graphics2D g2 = (Graphics2D) g.create();
DefaultCaret caret = (DefaultCaret) c;
Rectangle r = SwingUtilities.calculateInnerArea(this, rect);
r.y = caret.y;
r.height = caret.height;
g2.setPaint(LINE_COLOR);
g2.fill(r);
g2.dispose();
}
super.paintComponent(g);
}
use of javax.swing.text.DefaultCaret in project Universal-Pointer-Searcher by BullyWiiPlaza.
the class UniversalPointerSearcherGUI method setFoundPointersText.
private void setFoundPointersText(String foundPointersText) {
// Disable the cursor position from changing when the text area is updated
val caret = (DefaultCaret) foundPointersOutputArea.getCaret();
caret.setUpdatePolicy(NEVER_UPDATE);
foundPointersOutputArea.setText(foundPointersText);
}
use of javax.swing.text.DefaultCaret in project chatty by chatty.
the class DebugWindow method createLogArea.
private static JTextArea createLogArea() {
// Caret to prevent scrolling
DefaultCaret caret = new DefaultCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
JTextArea text = new JTextArea();
text.setEditable(false);
text.setFont(Font.decode(Font.MONOSPACED));
text.setCaret(caret);
return text;
}
Aggregations