예제 #1
0
    /**
     * Reinitialize the insets parameter with this Border's current Insets.
     *
     * @param c the component for which this border insets value applies
     * @param insets the object to be reinitialized
     */
    public Insets getBorderInsets(Component c, Insets insets) {
      if (!(c instanceof JPopupMenu)) {
        return insets;
      }
      FontMetrics fm;
      int descent = 0;
      int ascent = 16;

      String title = ((JPopupMenu) c).getLabel();
      if (title == null) {
        insets.left = insets.top = insets.right = insets.bottom = 0;
        return insets;
      }

      fm = c.getFontMetrics(font);

      if (fm != null) {
        descent = fm.getDescent();
        ascent = fm.getAscent();
      }

      insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT;
      return insets;
    }
예제 #2
0
 /**
  * Fetches the font metrics associated with the component hosting this view.
  *
  * @return the metrics
  */
 protected FontMetrics getFontMetrics() {
   Component c = getContainer();
   return c.getFontMetrics(c.getFont());
 }