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


Java BorderLayout.getConstraints方法代码示例

本文整理汇总了Java中java.awt.BorderLayout.getConstraints方法的典型用法代码示例。如果您正苦于以下问题:Java BorderLayout.getConstraints方法的具体用法?Java BorderLayout.getConstraints怎么用?Java BorderLayout.getConstraints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.BorderLayout的用法示例。


在下文中一共展示了BorderLayout.getConstraints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveToolbarConstraint

import java.awt.BorderLayout; //导入方法依赖的package包/类
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:NimbusLookAndFeel.java

示例2: initialize

import java.awt.BorderLayout; //导入方法依赖的package包/类
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);
    // Ignore the children of a JScrollPane.
    // Pending(milne) find a better way to do this.
    if (oldInstance instanceof javax.swing.JScrollPane) {
        return;
    }
    java.awt.Container oldC = (java.awt.Container)oldInstance;
    java.awt.Component[] oldChildren = oldC.getComponents();
    java.awt.Container newC = (java.awt.Container)newInstance;
    java.awt.Component[] newChildren = (newC == null) ? new java.awt.Component[0] : newC.getComponents();

    BorderLayout layout = ( oldC.getLayout() instanceof BorderLayout )
            ? ( BorderLayout )oldC.getLayout()
            : null;

    JLayeredPane oldLayeredPane = (oldInstance instanceof JLayeredPane)
            ? (JLayeredPane) oldInstance
            : null;

    // Pending. Assume all the new children are unaltered.
    for(int i = newChildren.length; i < oldChildren.length; i++) {
        Object[] args = ( layout != null )
                ? new Object[] {oldChildren[i], layout.getConstraints( oldChildren[i] )}
                : (oldLayeredPane != null)
                        ? new Object[] {oldChildren[i], oldLayeredPane.getLayer(oldChildren[i]), Integer.valueOf(-1)}
                        : new Object[] {oldChildren[i]};

        invokeStatement(oldInstance, "add", args, out);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:MetaData.java

示例3: validate

import java.awt.BorderLayout; //导入方法依赖的package包/类
private static void validate(JPanel panel) {
    BorderLayout layout = (BorderLayout) panel.getLayout();
    for (Component component : panel.getComponents()) {
        String name = (String) layout.getConstraints(component);
        if (name == null)
            throw new Error("The component is not layed out: " + component);

        JLabel label = (JLabel) component;
        if (!name.equals(label.getText()))
            throw new Error("The component is layed out on " + name + ": " + component);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test6437265.java


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