当前位置: 首页>>代码示例>>Java>>正文


Java MenuBarState类代码示例

本文整理汇总了Java中org.apache.harmony.awt.state.MenuBarState的典型用法代码示例。如果您正苦于以下问题:Java MenuBarState类的具体用法?Java MenuBarState怎么用?Java MenuBarState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MenuBarState类属于org.apache.harmony.awt.state包,在下文中一共展示了MenuBarState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layoutMenuBar

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public static void layoutMenuBar(MenuBarState s, int width) {

        Font f = s.getFont();
        FontMetrics fm = s.getFontMetrics(f);
        int lineHeight = getItemHeight(fm);
        int lines = 0;
        int lineWidth = 0;
        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            int itemWidth = getItemWidth(fm, is);
            if (itemWidth >= width) {
                lines += (lineWidth == 0 ? 1 : 2);
                lineWidth = 0;
                is.setItemBounds(0, lines * lineHeight, itemWidth, lineHeight);
                continue;
            }
            if (lineWidth + itemWidth > width) {
                lines ++;
                lineWidth = itemWidth;
                is.setItemBounds(0, lines * lineHeight, itemWidth, lineHeight);
                continue;
            }
            is.setItemBounds(lineWidth, lines * lineHeight, itemWidth, lineHeight);
            lineWidth += itemWidth;
        }
        if (lineWidth > 0) {
            lines ++;
        }

        s.setSize(width, lines * lineHeight + 1);
    }
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:32,代码来源:DefaultMenuBar.java

示例2: getPreferredWidth

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public static int getPreferredWidth(MenuBarState s) {
    int width = 0;
    Font f = s.getFont();
    FontMetrics fm = s.getFontMetrics(f);
    for (int i=0; i<s.getItemCount(); i++) {
        width += getItemWidth(fm, s.getItem(i));
    }
    return width;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:10,代码来源:DefaultMenuBar.java

示例3: drawMenuBar

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public static void drawMenuBar(MenuBarState s, Graphics g) {
    int width = s.getWidth(), height = s.getHeight();
    g.setColor(SystemColor.control);
    g.fillRect(0, 0, width, height);
    g.setColor(SystemColor.menu);
    g.drawLine(0, height-1, width-1, height-1);

    g.setFont(s.getFont());
    g.setColor(SystemColor.menuText);
    int selected = s.getSelectedItemIndex();
    for (int i=0; i<s.getItemCount(); i++) {
        MenuItemState is = s.getItem(i);
        Rectangle item = is.getItemBounds();
        Rectangle text = is.getTextBounds();

        if (!is.isEnabled()) {
            g.setColor(SystemColor.textInactiveText);
        } else if (i == selected) {
            g.setColor(SystemColor.textHighlight);
            g.fillRect(item.x, item.y, item.width, item.height);
            g.setColor(SystemColor.textHighlightText);
        } else {
            g.setColor(SystemColor.menuText);
        }
        g.drawString(is.getText(), item.x + text.x, item.y + text.y);
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:28,代码来源:DefaultMenuBar.java

示例4: getItemIndex

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public static int getItemIndex(MenuBarState s, Point p) {

        for (int i=0; i<s.getItemCount(); i++) {
            MenuItemState is = s.getItem(i);
            Rectangle bounds = is.getItemBounds();
            if (bounds.contains(p)) {
                return i;
            }
        }

        return -1;
    }
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:13,代码来源:DefaultMenuBar.java

示例5: getItemLocation

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public static Point getItemLocation(MenuBarState s, int index) {
    if (index < 0 || index >= s.getItemCount()) {
        return new Point(-1, -1);
    }

    MenuItemState is = s.getItem(index);
    Rectangle bounds = is.getItemBounds();
    Point where = new Point(bounds.x, bounds.y + bounds.height);
    Point screenPos = s.getLocationOnScreen();
    where.translate(screenPos.x, screenPos.y);
    return where;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:13,代码来源:DefaultMenuBar.java

示例6: drawMenuBar

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public void drawMenuBar(MenuBarState s, Graphics gr) {
    DefaultMenuBar.drawMenuBar(s, gr);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:4,代码来源:Theme.java

示例7: layoutMenuBar

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public void layoutMenuBar(MenuBarState s, int width) {
    DefaultMenuBar.layoutMenuBar(s, width);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:4,代码来源:Theme.java

示例8: getMenuBarItemIndex

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public int getMenuBarItemIndex(MenuBarState s, Point p) {
    return DefaultMenuBar.getItemIndex(s, p);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:4,代码来源:Theme.java

示例9: getMenuBarItemLocation

import org.apache.harmony.awt.state.MenuBarState; //导入依赖的package包/类
public Point getMenuBarItemLocation(MenuBarState s, int index) {
    return DefaultMenuBar.getItemLocation(s, index);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:4,代码来源:Theme.java


注:本文中的org.apache.harmony.awt.state.MenuBarState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。