Exemplo n.º 1
0
 protected Rectangle rectangleForCurrentValue() {
   int width = comboBox.getWidth();
   int height = comboBox.getHeight();
   Insets insets = getInsets();
   if (MotifGraphicsUtils.isLeftToRight(comboBox)) {
     return new Rectangle(
         insets.left,
         insets.top,
         (width - (insets.left + insets.right)) - iconAreaWidth(),
         height - (insets.top + insets.bottom));
   } else {
     return new Rectangle(
         insets.left + iconAreaWidth(),
         insets.top,
         (width - (insets.left + insets.right)) - iconAreaWidth(),
         height - (insets.top + insets.bottom));
   }
 }
Exemplo n.º 2
0
  public void paint(Graphics g, JComponent c) {
    boolean hasFocus = comboBox.hasFocus();
    Rectangle r;

    if (comboBox.isEnabled()) {
      g.setColor(comboBox.getBackground());
    } else {
      g.setColor(UIManager.getColor("ComboBox.disabledBackground"));
    }
    g.fillRect(0, 0, c.getWidth(), c.getHeight());

    if (!comboBox.isEditable()) {
      r = rectangleForCurrentValue();
      paintCurrentValue(g, r, hasFocus);
    }
    r = rectangleForArrowIcon();
    arrowIcon.paintIcon(c, g, r.x, r.y);
    if (!comboBox.isEditable()) {
      Border border = comboBox.getBorder();
      Insets in;
      if (border != null) {
        in = border.getBorderInsets(comboBox);
      } else {
        in = new Insets(0, 0, 0, 0);
      }
      // Draw the separation
      if (MotifGraphicsUtils.isLeftToRight(comboBox)) {
        r.x -= (HORIZ_MARGIN + 2);
      } else {
        r.x += r.width + HORIZ_MARGIN + 1;
      }
      r.y = in.top;
      r.width = 1;
      r.height = comboBox.getBounds().height - in.bottom - in.top;
      g.setColor(UIManager.getColor("controlShadow"));
      g.fillRect(r.x, r.y, r.width, r.height);
      r.x++;
      g.setColor(UIManager.getColor("controlHighlight"));
      g.fillRect(r.x, r.y, r.width, r.height);
    }
  }
Exemplo n.º 3
0
  protected Rectangle rectangleForArrowIcon() {
    Rectangle b = comboBox.getBounds();
    Border border = comboBox.getBorder();
    Insets in;
    if (border != null) {
      in = border.getBorderInsets(comboBox);
    } else {
      in = new Insets(0, 0, 0, 0);
    }
    b.x = in.left;
    b.y = in.top;
    b.width -= (in.left + in.right);
    b.height -= (in.top + in.bottom);

    if (MotifGraphicsUtils.isLeftToRight(comboBox)) {
      b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth();
    } else {
      b.x += HORIZ_MARGIN;
    }
    b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2;
    b.width = arrowIcon.getIconWidth();
    b.height = arrowIcon.getIconHeight();
    return b;
  }