javax.swing.JMenuItem.getBounds()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中javax.swing.JMenuItem.getBounds()方法的一些代码示例,展示了JMenuItem.getBounds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.getBounds()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:getBounds

JMenuItem.getBounds介绍

暂无

代码示例

代码示例来源:origin: org.java.net.substance/substance

@Override
public boolean isInside(MouseEvent me) {
  return this.menuItem.getBounds().contains(me.getX(), me.getY());
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
public boolean isInside(MouseEvent me) {
  return this.menuItem.getBounds().contains(me.getX(), me.getY());
}

代码示例来源:origin: stackoverflow.com

class CustomMenuUI extends BasicMenuUI {

  public static ComponentUI createUI(JComponent c) {
    return new CustomMenuUI();
  }

  @Override
  protected void paintText(Graphics g, JMenuItem menuItem,
      Rectangle textRect, String text) {
    g.setColor(Color.red);
    int w2 = menuItem.getBounds().width / 2;
    textRect.translate(w2 - textRect.width / 2, 0);
    super.paintText(g, menuItem, textRect, text);
  }

  @Override
  public Dimension getPreferredSize(JComponent c) {
    return new Dimension(80, 32);
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

public void stateChanged(ChangeEvent e) {
    if (e.getSource() instanceof JMenuItem) {
      if (((JMenuItem) e.getSource()).getModel().isArmed()) {
        popupMenu.scrollRectToVisible(((JMenuItem) e.getSource()).getBounds());
        Point position = contents.getViewport().getViewPosition();
        contents.getScrollUpButton().setEnabled(position.y > 2);
        contents.getScrollDownButton().setEnabled(position.y < contents.getViewport().getViewSize().height - contents.getViewport().getViewRect().height - 2);
      }
    }
  }
});

代码示例来源:origin: com.github.insubstantial/substance

@Override
  public void focusLost(FocusEvent e) {
    if (toRepaint()) {
      stateTransitionTracker.turnOffModelChangeTracking();
      menuItem.getModel().setRollover(false);
      stateTransitionTracker.onModelStateChanged();
      // fix for issue 371 - repaint the menu bar since the
      // menu is marked as flat
      Rectangle bounds = menuItem.getBounds();
      menuItem.getParent().repaint(bounds.x, bounds.y,
          bounds.width, bounds.height);
    }
  }
};

代码示例来源:origin: org.java.net.substance/substance

@Override
public void mouseEntered(MouseEvent e) {
  if (this.toRepaint()) {
    stateTransitionTracker.turnOffModelChangeTracking();
    menuItem.getModel().setRollover(true);
    stateTransitionTracker.onModelStateChanged();
    // fix for issue 371 - repaint the menu bar since the
    // menu is marked as flat
    Rectangle bounds = menuItem.getBounds();
    menuItem.getParent().repaint(bounds.x, bounds.y,
        bounds.width, bounds.height);
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
  public void mouseExited(MouseEvent e) {
    if (this.toRepaint()) {
      stateTransitionTracker.turnOffModelChangeTracking();
      menuItem.getModel().setRollover(false);
      stateTransitionTracker.onModelStateChanged();
      // fix for issue 371 - repaint the menu bar since the
      // menu is marked as flat
      Rectangle bounds = menuItem.getBounds();
      menuItem.getParent().repaint(bounds.x, bounds.y,
          bounds.width, bounds.height);
    }
  }
};

代码示例来源:origin: com.github.insubstantial/substance

@Override
public void mouseEntered(MouseEvent e) {
  if (this.toRepaint()) {
    stateTransitionTracker.turnOffModelChangeTracking();
    menuItem.getModel().setRollover(true);
    stateTransitionTracker.onModelStateChanged();
    // fix for issue 371 - repaint the menu bar since the
    // menu is marked as flat
    Rectangle bounds = menuItem.getBounds();
    menuItem.getParent().repaint(bounds.x, bounds.y,
        bounds.width, bounds.height);
  }
}

代码示例来源:origin: org.java.net.substance/substance

@Override
  public void mouseExited(MouseEvent e) {
    if (this.toRepaint()) {
      stateTransitionTracker.turnOffModelChangeTracking();
      menuItem.getModel().setRollover(false);
      stateTransitionTracker.onModelStateChanged();
      // fix for issue 371 - repaint the menu bar since the
      // menu is marked as flat
      Rectangle bounds = menuItem.getBounds();
      menuItem.getParent().repaint(bounds.x, bounds.y,
          bounds.width, bounds.height);
    }
  }
};

代码示例来源:origin: org.java.net.substance/substance

@Override
  public void focusLost(FocusEvent e) {
    if (toRepaint()) {
      stateTransitionTracker.turnOffModelChangeTracking();
      menuItem.getModel().setRollover(false);
      stateTransitionTracker.onModelStateChanged();
      // fix for issue 371 - repaint the menu bar since the
      // menu is marked as flat
      Rectangle bounds = menuItem.getBounds();
      menuItem.getParent().repaint(bounds.x, bounds.y,
          bounds.width, bounds.height);
    }
  }
};

相关文章

JMenuItem类方法