本文整理汇总了Java中javax.swing.text.JTextComponent.repaint方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.repaint方法的具体用法?Java JTextComponent.repaint怎么用?Java JTextComponent.repaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.JTextComponent
的用法示例。
在下文中一共展示了JTextComponent.repaint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCaretBoundsWithRepaint
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
* Set new caret bounds while repainting both original and new bounds.
* Clear the caret-painted and update-caret-bounds flags.
*
* @param newCaretBounds non-null new bounds
*/
synchronized Rectangle setCaretBoundsWithRepaint(Rectangle newCaretBounds, JTextComponent c, String logMessage, int logIndex) {
Rectangle oldCaretBounds = this.caretBounds;
boolean repaintOld = (oldCaretBounds != null && (this.statusBits & CARET_PAINTED) != 0);
this.statusBits &= ~(CARET_PAINTED | UPDATE_CARET_BOUNDS);
boolean log = EditorCaret.LOG.isLoggable(Level.FINE);
if (repaintOld) {
if (log) {
logRepaint(logMessage + "-setBoundsRepaint-repaintOld", logIndex, oldCaretBounds);
}
c.repaint(oldCaretBounds); // First schedule repaint of the original bounds (even if new bounds will possibly be the same)
}
if (!repaintOld || !newCaretBounds.equals(oldCaretBounds)) {
if (log) {
logRepaint(logMessage + "-setBoundsRepaint-repaintNew", logIndex, newCaretBounds);
}
c.repaint(newCaretBounds);
}
this.caretBounds = newCaretBounds;
return oldCaretBounds;
}
示例2: scrollToText
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
* Scrolls the specified text component so the text between the starting and ending index are visible.
*/
public static void scrollToText(JTextComponent textComponent, int startingIndex, int endingIndex) {
try {
Rectangle startingRectangle = textComponent.modelToView(startingIndex);
Rectangle endDingRectangle = textComponent.modelToView(endingIndex);
Rectangle totalBounds = startingRectangle.union(endDingRectangle);
textComponent.scrollRectToVisible(totalBounds);
textComponent.repaint();
} catch (BadLocationException e) {
e.printStackTrace();
}
}
示例3: updateRectangularSelectionPaintRect
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private void updateRectangularSelectionPaintRect() {
// Repaint current rect
JTextComponent c = component;
Rectangle repaintRect = rsPaintRect;
if (rsDotRect == null || rsMarkRect == null) {
return;
}
Rectangle newRect = new Rectangle();
if (rsDotRect.x < rsMarkRect.x) { // Swap selection to left
newRect.x = rsDotRect.x; // -1 to make the visual selection non-empty
newRect.width = rsMarkRect.x - newRect.x;
} else { // Extend or shrink on right
newRect.x = rsMarkRect.x;
newRect.width = rsDotRect.x - newRect.x;
}
if (rsDotRect.y < rsMarkRect.y) {
newRect.y = rsDotRect.y;
newRect.height = (rsMarkRect.y + rsMarkRect.height) - newRect.y;
} else {
newRect.y = rsMarkRect.y;
newRect.height = (rsDotRect.y + rsDotRect.height) - newRect.y;
}
if (newRect.width < 2) {
newRect.width = 2;
}
rsPaintRect = newRect;
// Repaint merged region with original rect
if (repaintRect == null) {
repaintRect = rsPaintRect;
} else {
repaintRect = repaintRect.union(rsPaintRect);
}
c.repaint(repaintRect);
updateRectangularSelectionPositionBlocks();
}
示例4: repaint
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
synchronized Rectangle repaint(JTextComponent c, String logMessage, int logIndex) {
Rectangle bounds = this.caretBounds;
if (bounds != null) {
this.statusBits &= ~CARET_PAINTED;
if (EditorCaret.LOG.isLoggable(Level.FINE)) {
logRepaint(logMessage, logIndex, bounds);
}
c.repaint(bounds);
}
return bounds;
}
示例5: repaintIfShowing
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
* Repaint caret bounds if the caret is showing or do nothing
* @param c
* @return
*/
synchronized Rectangle repaintIfShowing(JTextComponent c, String logMessage, int logIndex) {
Rectangle bounds = this.caretBounds;
if (bounds != null) {
boolean repaint = (this.statusBits & CARET_PAINTED) != 0;
if (repaint) {
this.statusBits &= ~CARET_PAINTED;
if (EditorCaret.LOG.isLoggable(Level.FINE)) {
logRepaint(logMessage + "-repaintIfShowing", logIndex, bounds);
}
c.repaint(bounds);
}
}
return bounds;
}