Exemplo n.º 1
0
  /**
   * DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  protected Rectangle getCancelButtonBounds() {
    JTextComponent c = getComponent();
    final int x = c.getWidth() - c.getHeight() / 2 - 9;
    final int y = c.getHeight() / 2 - 8;

    return new Rectangle(x, y, 17, 17);
  }
Exemplo n.º 2
0
 @Override
 protected void paintSafely(Graphics g) {
   super.paintSafely(g);
   JTextComponent comp = getComponent();
   if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
     if (color != null) {
       g.setColor(color);
     } else {
       g.setColor(comp.getForeground().brighter().brighter().brighter());
     }
     int padding = (comp.getHeight() - comp.getFont().getSize()) / 2;
     g.drawString(hint, 3, comp.getHeight() - padding - 1);
   }
 }
Exemplo n.º 3
0
  /**
   * DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  protected Rectangle getFindButtonBounds() {
    JTextComponent c = getComponent();
    final int x = c.getHeight() / 2 - 6;
    final int y = c.getHeight() / 2 - 6;

    return new Rectangle(x, y, 22, 17);
  }
Exemplo n.º 4
0
  /** DOCUMENT ME! */
  private void doPopup() {
    if (findPopup != null) {
      JTextComponent c = getComponent();

      findPopup.pack();
      // The "-1" just snugs us up a bit under the text field.
      findPopup.show(c, 0, c.getHeight() - 1);

      // Set focus back to the text field.
      // TODO Fix caret positioning, selection, etc.
      c.requestFocusInWindow();
    }
  }
Exemplo n.º 5
0
  protected void paintBackgroundSafely(final Graphics g) {
    final JTextComponent c = getComponent();
    final int width = c.getWidth();
    final int height = c.getHeight();

    // a delegate takes precedence
    if (delegate != null) {
      delegate.paint(c, g, 0, 0, width, height);
      return;
    }

    final boolean isOpaque = c.isOpaque();
    if (!(c.getBorder() instanceof AquaTextFieldBorder)) {
      // developer must have set a custom border
      if (!isOpaque && AquaUtils.hasOpaqueBeenExplicitlySet(c)) return;

      // must fill whole region with background color if opaque
      g.setColor(c.getBackground());
      g.fillRect(0, 0, width, height);
      return;
    }

    // using our own border
    g.setColor(c.getBackground());
    if (isOpaque) {
      g.fillRect(0, 0, width, height);
      return;
    }

    final Insets margin = c.getMargin();
    Insets insets = c.getInsets();

    if (insets == null) insets = new Insets(0, 0, 0, 0);
    if (margin != null) {
      insets.top -= margin.top;
      insets.left -= margin.left;
      insets.bottom -= margin.bottom;
      insets.right -= margin.right;
    }

    // the common case
    final int shrinkage = AquaTextFieldBorder.getShrinkageFor(c, height);
    g.fillRect(
        insets.left - 2,
        insets.top - shrinkage - 1,
        width - insets.right - insets.left + 4,
        height - insets.bottom - insets.top + shrinkage * 2 + 2);
  }