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


Java Constraints.setHeight方法代码示例

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


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

示例1: testConstraints_SetHeight

import javax.swing.SpringLayout.Constraints; //导入方法依赖的package包/类
public void testConstraints_SetHeight() throws Exception {
    layout.getConstraints(container).setHeight(Spring.constant(5));
    layout.getConstraints(button).setHeight(Spring.constant(6));
    layout.getConstraints(button).setHeight(Spring.constant(8));

    Constraints constraints = layout.getConstraints(textField);
    constraints.setHeight(Spring.constant(8));
    constraints.setY(Spring.constant(10));
    constraints.setConstraint(SpringLayout.EAST, Spring.constant(40));

    layout.getConstraints(panel).setHeight(Spring.constant(6));
    constraints.setY(Spring.constant(20));


    layout.getConstraints(innerButton).setHeight(Spring.constant(15));

    container.setSize(200, 300);
    layout.layoutContainer(container);

    assertEquals(300, container.getHeight());
    assertEquals(8, button.getHeight());
    assertEquals(8, textField.getHeight());
    assertEquals(6, panel.getHeight());
    assertEquals(0, innerButton.getHeight());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:SpringLayoutTest.java

示例2: testConstraints_SetY

import javax.swing.SpringLayout.Constraints; //导入方法依赖的package包/类
public void testConstraints_SetY() throws Exception {
    layout.getConstraints(container).setY(Spring.constant(5));
    layout.getConstraints(button).setY(Spring.constant(6));
    layout.getConstraints(button).setY(Spring.constant(8));

    Constraints constraints = layout.getConstraints(textField);
    constraints.setY(Spring.constant(8));
    constraints.setHeight(Spring.constant(10));
    constraints.setConstraint(SpringLayout.SOUTH, Spring.constant(40));

    layout.getConstraints(panel).setY(Spring.constant(6));
    constraints.setHeight(Spring.constant(20));


    layout.getConstraints(innerButton).setY(Spring.constant(15));

    container.setSize(200, 300);
    layout.layoutContainer(container);

    assertEquals(0, container.getY());
    assertEquals(8, button.getY());
    assertEquals(20, textField.getY());
    assertEquals(6, panel.getY());
    assertEquals(0, innerButton.getY());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:SpringLayoutTest.java

示例3: testInvalidateLayout

import javax.swing.SpringLayout.Constraints; //导入方法依赖的package包/类
public void testInvalidateLayout() throws Exception {
    JFrame frame = new JFrame("testMinimumLayoutSize");
    frame.setContentPane(container);
    layout = new SpringLayout();
    container.setLayout(layout);
    Constraints buttonConstraints = layout.getConstraints(button);
    buttonConstraints.setHeight(Spring.constant(33, 34, 35));
    Constraints containerConstraints = layout.getConstraints(container);
    containerConstraints.setConstraint(SpringLayout.SOUTH,
                                       buttonConstraints.getConstraint(SpringLayout.SOUTH));
    containerConstraints.setConstraint(SpringLayout.EAST,
                                       buttonConstraints.getConstraint(SpringLayout.EAST));
    containerConstraints.setConstraint(SpringLayout.WEST, Spring.constant(3));        
    frame.pack();
    frame.setVisible(true);
    frame.setSize(100, 200);

    Spring width = buttonConstraints.getWidth();
    if (isHarmony()) {
        assertEquals(5, width.getValue());
    } else {
        assertEquals(115, width.getValue());
    }
    frame.setSize(200, 300);
    layout.invalidateLayout(container);
    assertSame(width, buttonConstraints.getWidth());
    if (isHarmony()) {
        assertEquals(5, width.getValue());
    } else {
        assertEquals(115, width.getValue());
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:33,代码来源:SpringLayoutTest.java

示例4: testConstraints_GetHeight

import javax.swing.SpringLayout.Constraints; //导入方法依赖的package包/类
public void testConstraints_GetHeight() throws Exception {
    layout.getConstraints(container).setHeight(Spring.constant(5));
    layout.getConstraints(button).setHeight(Spring.constant(6));
    layout.getConstraints(button).setHeight(Spring.constant(8));

    Constraints constraints = layout.getConstraints(textField);
    constraints.setHeight(Spring.constant(8));
    constraints.setY(Spring.constant(10));
    constraints.setConstraint(SpringLayout.EAST, Spring.constant(40));

    layout.getConstraints(panel).setHeight(Spring.constant(6));
    constraints.setY(Spring.constant(20));


    layout.getConstraints(innerButton).setHeight(Spring.constant(15));

    container.setSize(200, 300);
    layout.layoutContainer(container);

    SpringTest.assertSizes(5, 5, 5,
                           layout.getConstraints(container).getHeight());
    SpringTest.assertSizes(8, 8, 8,
                           layout.getConstraints(button).getHeight());
    SpringTest.assertSizes(8, 8, 8,
                           layout.getConstraints(textField).getHeight());
    SpringTest.assertSizes(6, 6, 6,
                           layout.getConstraints(panel).getHeight());
    SpringTest.assertSizes(15, 15, 15,
                           layout.getConstraints(innerButton).getHeight());

    container.setSize(200, 300);
    layout.layoutContainer(button);
    SpringTest.assertSizes(8, 8, 8,
                           layout.getConstraints(button).getHeight());

}
 
开发者ID:shannah,项目名称:cn1,代码行数:37,代码来源:SpringLayoutTest.java

示例5: testConstraints_GetY

import javax.swing.SpringLayout.Constraints; //导入方法依赖的package包/类
public void testConstraints_GetY() throws Exception {
    layout.getConstraints(container).setY(Spring.constant(5));
    layout.getConstraints(button).setY(Spring.constant(6));
    layout.getConstraints(button).setY(Spring.constant(8));

    Constraints constraints = layout.getConstraints(textField);
    constraints.setY(Spring.constant(8));
    constraints.setHeight(Spring.constant(10));
    constraints.setConstraint(SpringLayout.SOUTH, Spring.constant(40));

    layout.getConstraints(panel).setY(Spring.constant(6));
    constraints.setHeight(Spring.constant(20));


    layout.getConstraints(innerButton).setY(Spring.constant(15));

    container.setSize(200, 300);
    layout.layoutContainer(container);

    SpringTest.assertSizes(0, 0, 0,
                           layout.getConstraints(container).getY());
    SpringTest.assertSizes(8, 8, 8,
                           layout.getConstraints(button).getY());
    SpringTest.assertSizes(20, 20, 20,
                           layout.getConstraints(textField).getY());
    SpringTest.assertSizes(6, 6, 6,
                           layout.getConstraints(panel).getY());
    SpringTest.assertSizes(15, 15, 15,
                           layout.getConstraints(innerButton).getY());

    container.setSize(200, 300);
    layout.layoutContainer(button);
    SpringTest.assertSizes(0, 0, 0, layout.getConstraints(button).getY());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:SpringLayoutTest.java

示例6: testMinimumLayoutSize

import javax.swing.SpringLayout.Constraints; //导入方法依赖的package包/类
public void testMinimumLayoutSize() throws Exception {
    //container
    setComponentSizes(button, Spring.constant(2, 5, 100), Spring.constant(3, 6, 101));
    Constraints buttonConstraints = layout.getConstraints(button);
    buttonConstraints.setHeight(Spring.constant(33, 34, 35));
    Constraints containerConstraints = layout.getConstraints(container);
    containerConstraints.setConstraint(SpringLayout.SOUTH,
                                       buttonConstraints.getConstraint(SpringLayout.SOUTH));
    containerConstraints.setConstraint(SpringLayout.EAST,
                                       buttonConstraints.getConstraint(SpringLayout.EAST));
    containerConstraints.setConstraint(SpringLayout.WEST, Spring.constant(3));
    layout.layoutContainer(container);
    assertEquals(2, layout.minimumLayoutSize(container).width);
    assertEquals(33, layout.minimumLayoutSize(container).height);

    //putConstraints()
    assertEquals(button.getInsets().left + button.getInsets().right,
                 layout.minimumLayoutSize(button).width);

    assertEquals(panel.getInsets().left + panel.getInsets().right,
                 layout.minimumLayoutSize(panel).width);

    assertEquals(innerButton.getInsets().left + innerButton.getInsets().right,
                 layout.minimumLayoutSize(innerButton).width);

    buttonConstraints.setX(Spring.constant(20));
    assertEquals(button.getInsets().left + button.getInsets().right,
                 layout.minimumLayoutSize(button).width);
    assertEquals(0, layout.getConstraint(SpringLayout.EAST, button).getPreferredValue());

    buttonConstraints.setWidth(Spring.constant(100));
    assertEquals(100 + button.getInsets().left + button.getInsets().right,
                 layout.minimumLayoutSize(button).width);

    layout.getConstraints(innerButton).setX(Spring.constant(20));
    assertEquals(innerButton.getInsets().left + innerButton.getInsets().right,
                 layout.minimumLayoutSize(innerButton).width);

    layout.getConstraints(innerButton).setWidth(Spring.constant(100));
    assertEquals(100 + innerButton.getInsets().left + innerButton.getInsets().right,
                 layout.minimumLayoutSize(innerButton).width);

    layout.getConstraints(panel).setX(Spring.constant(20));
    assertEquals(panel.getInsets().left + panel.getInsets().right,
                 layout.minimumLayoutSize(panel).width);
    assertEquals(0, layout.getConstraint(SpringLayout.EAST, panel).getPreferredValue());

    layout.getConstraints(panel).setWidth(Spring.constant(100));
    assertEquals(100 + panel.getInsets().left + panel.getInsets().right,
                 layout.minimumLayoutSize(panel).width);
    assertEquals(100, layout.getConstraint(SpringLayout.EAST, panel).getPreferredValue());


    layout = new SpringLayout();
    container.setLayout(layout);
    layout.putConstraint(SpringLayout.SOUTH, button, Spring.constant(15),
                         SpringLayout.NORTH, container);
    layout.putConstraint(SpringLayout.EAST, button, Spring.constant(5),
                         SpringLayout.WEST, container);
    assertEquals(panel.getInsets().left + panel.getInsets().right,
                 layout.minimumLayoutSize(panel).width);
    assertEquals(innerButton.getInsets().left + innerButton.getInsets().right,
                 layout.minimumLayoutSize(innerButton).width);

    assertEquals(5 + button.getInsets().left + button.getInsets().right,
                 layout.minimumLayoutSize(button).width);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:68,代码来源:SpringLayoutTest.java


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