Examples of ButtonModel


Examples of javax.swing.ButtonModel

     * @param text String to render
     */
  protected void paintText(Graphics g, JMenuItem menuItem,
            Rectangle textRect, String text) {

    ButtonModel model = menuItem.getModel();

    if(!model.isEnabled()) {
      OfficeXPGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
    }
    else {
      FontMetrics fm = menuItem.getFontMetrics(g.getFont());
      int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
View Full Code Here

Examples of javax.swing.ButtonModel

   */
  public static void paintMenuItemIcon(Graphics g, JMenuItem menuItem,
                  Rectangle iconRect) {

    Icon icon;
    ButtonModel model = menuItem.getModel();

    if(!model.isEnabled()) {
      OfficeXPUtilities.paintDisabledButtonIcon(g, menuItem, iconRect);
    }

    else if(model.isPressed() && model.isArmed()) {
      icon = (Icon) menuItem.getPressedIcon();
      if(icon == null) {
        // Use default icon
        icon = (Icon) menuItem.getIcon();
      }
      if (icon!=null)
        icon.paintIcon(menuItem,g, iconRect.x,iconRect.y);
    }

    else {
      icon = (Icon) menuItem.getIcon();
      if (icon!=null) {
        if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) {
          Icon disabledIcon = (Icon)menuItem.getDisabledIcon();
          // Sometimes this is null.  This will result in no
          // shadow under the "raised up" icon, but oh well...
          if (disabledIcon!=null)
            disabledIcon.paintIcon(menuItem,g, iconRect.x,iconRect.y);
View Full Code Here

Examples of javax.swing.ButtonModel

   * OfficeXPMenuItemUI.paintBackground() - see "if (model.isSelected())"
   * line...
   */
  protected void paintSubmenuBackground(Graphics g, JMenu menu) {

    ButtonModel model = menu.getModel();
    Color oldColor = g.getColor();
    int menuWidth = menu.getWidth();
    int menuHeight = menu.getHeight();

    paintUnarmedBackground(g, menu);

    //if (model.isArmed() || model.isSelected()) {
    if (model.isSelected()) {

      int width = menuWidth - 3;
      int height = menuHeight - 2;

      g.setColor(UIManager.getColor("OfficeLnF.HighlightBorderColor"));
View Full Code Here

Examples of javax.swing.ButtonModel

     * @param text String to render
     */
    protected void paintText(Graphics g, JMenuItem menuItem,
                  Rectangle textRect, String text) {

    ButtonModel model = menuItem.getModel();

    if(!model.isEnabled()) {
        OfficeXPGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
    }
    else {
        FontMetrics fm = menuItem.getFontMetrics(g.getFont());
        int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
View Full Code Here

Examples of javax.swing.ButtonModel

    }


  protected void paintTopLevelMenuBackground(Graphics g, JMenu menu) {

    ButtonModel model = menu.getModel();
    Color oldColor = g.getColor();
    int menuWidth = menu.getWidth();
    int menuHeight = menu.getHeight();

    if (model.isArmed() || model.isSelected()) {

      // Fill-in with color.
      g.setColor(UIManager.getColor("OfficeXPLnF.ChosenMenuColor"));
      g.fillRect(0,0, menuWidth,menuHeight);

      // Draw the "border."
      JPopupMenu popupMenu = menu.getPopupMenu();
      JMenuBar menuBar = (JMenuBar)menu.getParent();
      Point menuLocation = menu.getLocation();
      Point popupMenuLocation = SwingUtilities.convertPoint(popupMenu,
                  popupMenu.getLocation(), menuBar);
      //int newX = menuLocation.x - popupMenuLocation.x + 1;
      g.setColor(UIManager.getDefaults().getColor("OfficeLnF.MenuBorderColor"));
      // If the popup menu is below the menu bar or the popup isn't visible
      // (happens if the user presses "Alt" to activate the menus).
      if (menuLocation.y<popupMenuLocation.y || !menu.isPopupMenuVisible()) {

        g.drawLine(0,2, 0,menuHeight-1);
        g.drawLine(0,2, menuWidth-5,2);
        g.drawLine(menuWidth-5,2, menuWidth-5,menuHeight-1);
/*
        // Shadow - NOT ACCURATE!!
        g.setColor(new Color(225,225,225));
        g.fillRect(menuWidth-4,6,  4,menuHeight);
        g.setColor(new Color(210,210,210));
        g.fillRect(menuWidth-4,8,  3,menuHeight);
        g.setColor(new Color(180,180,180));
        g.drawLine(menuWidth-4,10,  menuWidth-4,menuHeight);
        g.setColor(new Color(195,195,195));
        g.drawLine(menuWidth-3,10, menuWidth-3,menuHeight);
*/
      }
      // If the popup menu is above the menu bar.
      else {

        g.drawLine(0,0, 0,menuHeight-2);
        g.drawLine(0,menuHeight-2, menuWidth-5,menuHeight-2);
        g.drawLine(menuWidth-5,0, menuWidth-5,menuHeight-2);

        // Shadow ... ???

      }

    }

    else {

      // Needed by both items below.
      g.setColor(menu.getBackground());
      g.fillRect(0,0, menuWidth, menuHeight);

      if (isMouseOver() && model.isEnabled()) {
        g.setColor(UIManager.getColor("OfficeLnF.HighlightBorderColor"));
        g.drawRect(0,2, menuWidth-5,menuHeight-3);
        g.setColor(UIManager.getColor("OfficeLnF.HighlightColor"));
        g.fillRect(1,3, menuWidth-6,menuHeight-4);
      }
View Full Code Here

Examples of javax.swing.ButtonModel

     * @param text String to render
     */
    public static void paintText(Graphics g, AbstractButton b,
            Rectangle textRect, String text, int textShiftOffset) {

    ButtonModel model = b.getModel();
    FontMetrics fm = b.getFontMetrics(g.getFont());

    int mnemIndex = b.getDisplayedMnemonicIndex();
    // W2K Feature: Check to see if the Underscore should be rendered.
    if (WindowsLookAndFeel.isMnemonicHidden())
      mnemIndex = -1;

    /* Draw the Text */
    Color color = b.getForeground();
    if(model.isEnabled()) {
        /*** paint the text normally */
        g.setColor(color);
        OfficeXPGraphicsUtils.drawStringUnderlineCharAt(g,fm,text, mnemIndex,
              textRect.x + textShiftOffset,
              textRect.y + fm.getAscent() + textShiftOffset);
View Full Code Here

Examples of javax.swing.ButtonModel

   * @param c The button, whose parent is a <code>JToolBar</code>.
   */
  protected void paintToolbarButtonBackground(Graphics g, JComponent c) {

    AbstractButton button = (AbstractButton)c;
    ButtonModel model = button.getModel();

    int width = button.getWidth() - 1;
    int height = button.getHeight() - 1;

    // This case is when the button isn't even enabled.
    if (!model.isEnabled()) {
      /* Do nothing. */
    }

    // This case is when the user has down-clicked, and the mouse is
    // still over the button.
    else if (model.isArmed()) {
      Office2003ButtonUI.paintArmedToolbarButtonBackground(g,
                        width, height);
    }

    // This case is when the mouse is hovering over the button, or
    // they've left-clicked, but moved the mouse off the button.
    else if (isMouseOver() || model.isPressed()) {
      Office2003ButtonUI.paintMouseOverToolbarButtonBackground(g,
                        width, height);
    }

    // This case is when the user hasn't clicked on the button, nor is
View Full Code Here

Examples of javax.swing.ButtonModel

  }


    protected void paintTopLevelMenuBackground(Graphics g, JMenu menu) {

    ButtonModel model = menuItem.getModel();
    Color oldColor = g.getColor();
    int menuWidth = menu.getWidth();
    int menuHeight = menu.getHeight();

    if (model.isArmed() || model.isSelected()) {

      // Draw the "border."
      JPopupMenu popupMenu = menu.getPopupMenu();
      JMenuBar menuBar = (JMenuBar)menu.getParent();
      Point menuLocation = menu.getLocation();
      Point popupMenuLocation = SwingUtilities.convertPoint(
              popupMenu, popupMenu.getLocation(), menuBar);
      //int topLevelMenuWidth = menu.getWidth();
      //int newX = menuLocation.x - popupMenuLocation.x + 1;
      g.setColor(UIManager.getDefaults().getColor("OfficeLnF.MenuBorderColor"));

      // If the popup menu is below the menu bar or the popup isn't visible
      // (happens if the user presses "Alt" to activate the menus).
      if (menuLocation.y<popupMenuLocation.y || !menu.isPopupMenuVisible()) {

        g.drawLine(0,2, 0,menuHeight);
        g.drawLine(0,2, menuWidth-5,2);
        g.drawLine(menuWidth-5,2, menuWidth-5,menuHeight);

        // Fill in the inside of the menu item.
        Color beginColor = UIManager.getColor("Office2003LnF.MenuBarItemSelectedBeginGradientColor");
        Color endColor   = UIManager.getColor("Office2003LnF.MenuBarItemSelectedEndGradientColor");
        Graphics2D g2d = (Graphics2D) g;
        GradientPaint paint = new GradientPaint(
                  0.0f, 0.0f, beginColor,
                  0.0f, menu.getHeight(), endColor);
        g2d.setPaint(paint);
        g.fillRect(1,3, menuWidth-6,menuHeight-3);

      }

      // If the popup menu is above the menu bar.
      else {

        g.drawLine(0,0, 0,menuHeight-2);
        g.drawLine(0,menuHeight-2, menuWidth-5,menuHeight-2);
        g.drawLine(menuWidth-5,0, menuWidth-5,menuHeight-2);

        // Fill in the inside of the menu item.
        Color beginColor = UIManager.getColor("Office2003LnF.MenuBarItemSelectedBeginGradientColor");
        Color endColor   = UIManager.getColor("Office2003LnF.MenuBarItemSelectedEndGradientColor");
        Graphics2D g2d = (Graphics2D) g;
        GradientPaint paint = new GradientPaint(
                  0.0f, 0.0f, beginColor,
                  0.0f, menu.getHeight(), endColor);
        g2d.setPaint(paint);
        g.fillRect(1,0, menuWidth-6,menuHeight-3);

      }

    }

    else {

      if (isMouseOver() && model.isEnabled()) {

        g.setColor(UIManager.getColor("OfficeLnF.HighlightBorderColor"));
        g.drawRect(0,2, menuWidth-5,menuHeight-3);

        Color beginColor = UIManager.getColor("Office2003LnF.MenuBarItemArmedBeginGradientColor");
View Full Code Here

Examples of javax.swing.ButtonModel

   */
  public static void paintButtonIcon(Graphics g, JComponent c,
                    Rectangle iconRect) {

    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    Icon icon;

    if (!model.isEnabled()) {
      OfficeXPUtilities.paintDisabledButtonIcon(g, b, iconRect);
    }
    else {
      icon = (Icon)b.getIcon();
      if (icon!=null)
View Full Code Here

Examples of javax.swing.ButtonModel

        tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition",
                                  ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last");

        int         oldState    = tabContext.getComponentState();
        ButtonModel model       = scrollButton.getModel();
        int         isPressed   = model.isPressed() && model.isArmed() ? PRESSED : 0;
        int         buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed;

        tabContext.setComponentState(buttonState);
        tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement);
        tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.