Пример #1
0
 /** {@inheritDoc} */
 public void paint(Graphics g) {
   if (isVisible() && overwriteMode) {
     Rectangle r = null;
     int pos = editor.getCaretPosition();
     try {
       r = editor.modelToView(pos);
     } catch (BadLocationException e) {
     }
     if (r != null && (r.width != 0 || r.height != 0)) {
       if ((x != r.x) || (y != r.y)) {
         repaint();
         x = r.x;
         y = r.y;
         height = r.height;
         width = editor.getFontMetrics(editor.getFont()).charWidth('W') + 1;
       } else {
         g.setColor(editor.getCaretColor());
         g.setXORMode(editor.getBackground());
         g.fillRect(x, y, width, height);
       }
     }
   } else {
     super.paint(g);
   }
 }
Пример #2
0
 // See <rdar://problem/3833837> 1.4.2_05-141.3: JTextField performance with
 // Aqua L&F. We are getting into a circular condition with the BasicCaret
 // paint code since it doesn't know about the fact that our damage routine
 // above elminates the border. Sadly we can't easily change either one, so
 // we will add a painting flag and not damage during a repaint.
 @Override
 public void paint(final Graphics g) {
   if (isVisible()) {
     fPainting = true;
     super.paint(g);
     fPainting = false;
   }
 }