⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oyoahapaintmenu.java

📁 java 开源,Swing外观:JGoodies look & feel. ... JGoodies look&feels让你的Swing 应用程序与applets看起来更漂亮.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      menuItem, fm, b.getText(), fmAccel, acceleratorText, b.getIcon(),      checkIcon, arrowIcon,      b.getVerticalAlignment(), b.getHorizontalAlignment(),      b.getVerticalTextPosition(), b.getHorizontalTextPosition(),      viewRect, iconRect, textRect, acceleratorRect,      checkIconRect, arrowIconRect,      b.getText() == null ? 0 : defaultTextIconGap,      defaultTextIconGap    );    // Paint the Check    if (checkIcon != null)    {      if(model.isArmed() || (c instanceof JMenu && model.isSelected()))      {        g.setColor(foreground);      }      else      {        g.setColor(b.getForeground());      }      if(useCheckAndArrow(menuItem))      {        checkIcon.paintIcon(c, g, checkIconRect.x, checkIconRect.y);      }      g.setColor(holdc);    }    // Paint the Icon    if(b.getIcon() != null)    {      Icon icon;      if(!model.isEnabled())      {        icon = (Icon) b.getDisabledIcon();      }      else      if(model.isPressed() && model.isArmed())      {        icon = (Icon) b.getPressedIcon();        if(icon == null)        {          // Use default icon          icon = (Icon) b.getIcon();        }      }      else      {        icon = (Icon) b.getIcon();      }      if(icon!=null)      {        icon.paintIcon(c, g, iconRect.x, iconRect.y);      }    }    drawText(g, b, model, fm, text, foreground);    // Draw the Accelerator Text    if(acceleratorText != null && !acceleratorText.equals(""))    {      g.setFont(acceleratorFont);      if(!model.isEnabled())      {        // *** paint the acceleratorText disabled        if (disabledForeground != null)        {          g.setColor(disabledForeground);          BasicGraphicsUtils.drawString(g,acceleratorText,0, acceleratorRect.x, acceleratorRect.y + fmAccel.getAscent());        }        else        {          g.setColor(b.getBackground().brighter());          BasicGraphicsUtils.drawString(g,acceleratorText,0, acceleratorRect.x, acceleratorRect.y + fmAccel.getAscent());          g.setColor(b.getBackground().darker());          BasicGraphicsUtils.drawString(g,acceleratorText,0, acceleratorRect.x - 1, acceleratorRect.y + fmAccel.getAscent() - 1);        }      }      else      {        // *** paint the acceleratorText normally        if (model.isArmed()|| (c instanceof JMenu && model.isSelected()))        {          g.setColor( acceleratorSelectionForeground );        }        else        {          g.setColor( acceleratorForeground );        }        BasicGraphicsUtils.drawString(g,acceleratorText, 0, acceleratorRect.x, acceleratorRect.y + fmAccel.getAscent());      }    }    // Paint the Arrow    if (arrowIcon != null)    {      if(model.isArmed() || (c instanceof JMenu &&model.isSelected()))      {        g.setColor(foreground);      }      if(useCheckAndArrow(menuItem))      {        arrowIcon.paintIcon(c, g, arrowIconRect.x, arrowIconRect.y);      }    }    g.setColor(holdc);    g.setFont(holdf);  }    protected String layoutMenuItem(      JMenuItem menuItem,      FontMetrics fm,      String text,      FontMetrics fmAccel,      String acceleratorText,      Icon icon,      Icon checkIcon,      Icon arrowIcon,      int verticalAlignment,      int horizontalAlignment,      int verticalTextPosition,      int horizontalTextPosition,      Rectangle viewRect,      Rectangle iconRect,      Rectangle textRect,      Rectangle acceleratorRect,      Rectangle checkIconRect,      Rectangle arrowIconRect,      int textIconGap,      int menuItemGap)    {        SwingUtilities.layoutCompoundLabel(                            menuItem, fm, text, icon, verticalAlignment,                            horizontalAlignment, verticalTextPosition,                            horizontalTextPosition, viewRect, iconRect, textRect,                            textIconGap);        /* Initialize the acceelratorText bounds rectangle textRect.  If a null         * or and empty String was specified we substitute "" here         * and use 0,0,0,0 for acceleratorTextRect.         */        if((acceleratorText == null) || acceleratorText.equals(""))        {            acceleratorRect.width = acceleratorRect.height = 0;            acceleratorText = "";        }        else        {            acceleratorRect.width = SwingUtilities.computeStringWidth( fmAccel, acceleratorText );            acceleratorRect.height = fmAccel.getHeight();        }        /* Initialize the checkIcon bounds rectangle's width & height.         */	if(useCheckAndArrow(menuItem))	{	    if (checkIcon != null)	    {              checkIconRect.width = checkIcon.getIconWidth();              checkIconRect.height = checkIcon.getIconHeight();	    }	    else	    {              checkIconRect.width = checkIconRect.height = 0;	    }          /* Initialize the arrowIcon bounds rectangle width & height.           */          if (arrowIcon != null)          {            arrowIconRect.width = arrowIcon.getIconWidth();            arrowIconRect.height = arrowIcon.getIconHeight();          }          else          {            arrowIconRect.width = arrowIconRect.height = 0;          }        }        Rectangle labelRect = iconRect.union(textRect);        if(OyoahaUtilities.isLeftToRight(menuItem))        {          textRect.x += menuItemGap;          iconRect.x += menuItemGap;          // Position the Accelerator text rect          acceleratorRect.x = viewRect.x + viewRect.width - arrowIconRect.width - menuItemGap - acceleratorRect.width;          // Position the Check and Arrow Icons          if(useCheckAndArrow(menuItem))          {            checkIconRect.x = viewRect.x + menuItemGap;            textRect.x += menuItemGap + checkIconRect.width;            iconRect.x += menuItemGap + checkIconRect.width;            arrowIconRect.x = viewRect.x + viewRect.width - menuItemGap - arrowIconRect.width;          }        }        else        {          textRect.x -= menuItemGap;          iconRect.x -= menuItemGap;          // Position the Accelerator text rect          acceleratorRect.x = viewRect.x + arrowIconRect.width + menuItemGap;          // Position the Check and Arrow Icons          if (useCheckAndArrow(menuItem))          {            checkIconRect.x = viewRect.x + viewRect.width - menuItemGap - checkIconRect.width;            textRect.x -= menuItemGap + checkIconRect.width;            iconRect.x -= menuItemGap + checkIconRect.width;            arrowIconRect.x = viewRect.x + menuItemGap;          }        }        // Align the accelertor text and the check and arrow icons vertically        // with the center of the label rect.        acceleratorRect.y = labelRect.y + (labelRect.height/2) - (acceleratorRect.height/2);        if( useCheckAndArrow(menuItem) )        {          arrowIconRect.y = labelRect.y + (labelRect.height/2) - (arrowIconRect.height/2);          checkIconRect.y = labelRect.y + (labelRect.height/2) - (checkIconRect.height/2);        }        return text;    }  /*  * Returns false if the component is a JMenu and it is a top  * level menu (on the menubar).  */  protected boolean useCheckAndArrow(JMenuItem menuItem)  {    boolean b = true;    if((menuItem instanceof JMenu) && (((JMenu)menuItem).isTopLevelMenu()))    {      b = false;    }    return b;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -