本文整理汇总了Java中com.jgoodies.forms.factories.CC类的典型用法代码示例。如果您正苦于以下问题:Java CC类的具体用法?Java CC怎么用?Java CC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CC类属于com.jgoodies.forms.factories包,在下文中一共展示了CC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExtraExpansionHonorsCurrentMeasure
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks and verifies that components that span multiple columns
* and that expand the container are measured using the correct measure.
*/
public static void testExtraExpansionHonorsCurrentMeasure() {
TestComponent c1 = new TestComponent(10, 1, 50, 1);
TestComponent c2 = new TestComponent(10, 1, 50, 1);
TestComponent c3 = new TestComponent(10, 1, 50, 1);
TestComponent c4 = new TestComponent(10, 1, 50, 1);
FormLayout layout = new FormLayout(
"10px, 15px:grow, 20px",
"pref, pref");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy (1, 1));
panel.add(c2, CC.xy (2, 1));
panel.add(c3, CC.xy (3, 1));
panel.add(c4, CC.xyw(1, 2, 2));
int minimumLayoutWidth = layout.minimumLayoutSize(panel).width;
int preferredLayoutWidth = layout.preferredLayoutSize(panel).width;
assertEquals("Minimum layout width", 45, minimumLayoutWidth);
assertEquals("Preferred layout width", 70, preferredLayoutWidth);
}
示例2: testHorizontalAlignments
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks whether components are aligned according to the column specs.
*/
public static void testHorizontalAlignments() {
TestComponent left = new TestComponent(2, 7, 4, 9);
TestComponent center = new TestComponent(2, 7, 4, 9);
TestComponent right = new TestComponent(2, 7, 4, 9);
TestComponent fill = new TestComponent(2, 7, 4, 9);
TestComponent def = new TestComponent(2, 7, 4, 9);
FormLayout layout = new FormLayout(
"left:10px, center:10px, right:10px, fill:10px, 10px",
"pref");
JPanel panel = new JPanel(layout);
panel.add(left, CC.xy(1, 1));
panel.add(center, CC.xy(2, 1));
panel.add(right, CC.xy(3, 1));
panel.add(fill, CC.xy(4, 1));
panel.add(def, CC.xy(5, 1));
panel.doLayout();
assertEquals("Left.x", 0, left.getX());
assertEquals("Left.width", 4, left.getWidth());
assertEquals("Center.x", 13, center.getX());
assertEquals("Center.width", 4, center.getWidth());
assertEquals("Right.x", 26, right.getX());
assertEquals("Right.width", 4, right.getWidth());
assertEquals("Fill.x", 30, fill.getX());
assertEquals("Fill.width", 10, fill.getWidth());
assertEquals("Default.x", 40, def.getX());
assertEquals("Default.width", 10, def.getWidth());
}
示例3: testVerticalAlignments
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks whether components are aligned according to the row specs.
*/
public static void testVerticalAlignments() {
TestComponent top = new TestComponent(7, 2, 9, 4);
TestComponent center = new TestComponent(7, 2, 9, 4);
TestComponent bottom = new TestComponent(7, 2, 9, 4);
TestComponent fill = new TestComponent(7, 2, 9, 4);
TestComponent def = new TestComponent(7, 2, 9, 4);
FormLayout layout = new FormLayout(
"pref",
"top:10px, center:10px, bottom:10px, fill:10px, 10px");
JPanel panel = new JPanel(layout);
panel.add(top, CC.xy(1, 1));
panel.add(center, CC.xy(1, 2));
panel.add(bottom, CC.xy(1, 3));
panel.add(fill, CC.xy(1, 4));
panel.add(def, CC.xy(1, 5));
panel.doLayout();
assertEquals("Top.y", 0, top.getY());
assertEquals("Top.height", 4, top.getHeight());
assertEquals("Center.y", 13, center.getY());
assertEquals("Center.height", 4, center.getHeight());
assertEquals("Bottom.y", 26, bottom.getY());
assertEquals("Bottom.height", 4, bottom.getHeight());
assertEquals("Fill.y", 30, fill.getY());
assertEquals("Fill.height", 10, fill.getHeight());
assertEquals("Default.y", 43, def.getY());
assertEquals("Default.height", 4, def.getHeight());
}
示例4: testBoundedWidth
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Tests bounded min and pref widths.
*/
public static void testBoundedWidth() {
TestComponent c1 = new TestComponent( 2, 7, 4, 9);
TestComponent c2 = new TestComponent(20, 7, 40, 9);
TestComponent c3 = new TestComponent( 2, 7, 4, 9);
TestComponent c4 = new TestComponent(20, 7, 40, 9);
TestComponent c5 = new TestComponent( 2, 7, 4, 9);
TestComponent c6 = new TestComponent(20, 7, 40, 9);
TestComponent c7 = new TestComponent( 2, 7, 4, 9);
TestComponent c8 = new TestComponent(20, 7, 40, 9);
FormLayout layout = new FormLayout(
"[10px,min], [10px,min], " +
"[10px,pref], [10px,pref], " +
"[min,10px], [min,10px], " +
"[pref,10px], [pref,10px]",
"pref");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy(1, 1));
panel.add(c2, CC.xy(2, 1));
panel.add(c3, CC.xy(3, 1));
panel.add(c4, CC.xy(4, 1));
panel.add(c5, CC.xy(5, 1));
panel.add(c6, CC.xy(6, 1));
panel.add(c7, CC.xy(7, 1));
panel.add(c8, CC.xy(8, 1));
panel.doLayout();
assertEquals("max(10px;c1_min).width", 10, c1.getWidth());
assertEquals("max(10px;c2_min).width", 20, c2.getWidth());
assertEquals("max(10px;c3_pref).width", 10, c3.getWidth());
assertEquals("max(10px;c4_pref).width", 40, c4.getWidth());
assertEquals("min(10px;c5_min).width", 2, c5.getWidth());
assertEquals("min(10px;c6_min).width", 10, c6.getWidth());
assertEquals("min(10px;c7_pref).width", 4, c7.getWidth());
assertEquals("min(10px;c8_pref).width", 10, c8.getWidth());
}
示例5: testBoundedHeight
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Tests bounded min and pref widths.
*/
public static void testBoundedHeight() {
TestComponent c1 = new TestComponent(7, 2, 9, 4);
TestComponent c2 = new TestComponent(7, 20, 9, 40);
TestComponent c3 = new TestComponent(7, 2, 9, 4);
TestComponent c4 = new TestComponent(7, 20, 9, 40);
TestComponent c5 = new TestComponent(7, 2, 9, 4);
TestComponent c6 = new TestComponent(7, 20, 9, 40);
TestComponent c7 = new TestComponent(7, 2, 9, 4);
TestComponent c8 = new TestComponent(7, 20, 9, 40);
FormLayout layout = new FormLayout(
"pref",
"f:[10px,min], f:[10px,min], " +
"f:[10px,pref], f:[10px,pref], " +
"f:[min,10px], f:[min,10px], " +
"f:[pref,10px], f:[pref,10px]");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy(1, 1));
panel.add(c2, CC.xy(1, 2));
panel.add(c3, CC.xy(1, 3));
panel.add(c4, CC.xy(1, 4));
panel.add(c5, CC.xy(1, 5));
panel.add(c6, CC.xy(1, 6));
panel.add(c7, CC.xy(1, 7));
panel.add(c8, CC.xy(1, 8));
panel.doLayout();
assertEquals("[10px, c1_min].height", 10, c1.getHeight());
assertEquals("[10px, c2_min].height", 20, c2.getHeight());
assertEquals("[10px,c3_pref].height", 10, c3.getHeight());
assertEquals("[10px,c4_pref].height", 40, c4.getHeight());
assertEquals("[c5_min, 10px].height", 2, c5.getHeight());
assertEquals("[c6_min, 10px].height", 10, c6.getHeight());
assertEquals("[c7_pref,10px].height", 4, c7.getHeight());
assertEquals("[c8_pref,10px].height", 10, c8.getHeight());
}
示例6: testNoExtraExpansionIfAllColumnsAreFixed
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks and verifies that components that span multiple columns
* do not expand the container of no column grows.
*/
public static void testNoExtraExpansionIfAllColumnsAreFixed() {
TestComponent c1 = new TestComponent(10, 1, 50, 1);
TestComponent c2 = new TestComponent(10, 1, 50, 1);
TestComponent c3 = new TestComponent(10, 1, 50, 1);
TestComponent c4 = new TestComponent(10, 1, 50, 1);
FormLayout layout = new FormLayout(
"10px, 15px, 20px",
"pref, pref");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy (1, 1));
panel.add(c2, CC.xy (2, 1));
panel.add(c3, CC.xy (3, 1));
panel.add(c4, CC.xyw(1, 2, 2));
Dimension preferredLayoutSize = layout.preferredLayoutSize(panel);
panel.setSize(preferredLayoutSize);
panel.doLayout();
int col1And2Width = c2.getX() + c2.getWidth();
int gridWidth = c3.getX() + c3.getWidth();
int totalWidth = preferredLayoutSize.width;
assertEquals("Col1+2 width", 25, col1And2Width);
assertEquals("Grid width", 45, gridWidth);
assertEquals("Total width", 45, totalWidth);
}
示例7: testNoExtraExpansionIfSpannedColumnsAreFixed
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks and verifies that components that span multiple columns
* do not expand the container of no column grows.
*/
public static void testNoExtraExpansionIfSpannedColumnsAreFixed() {
TestComponent c1 = new TestComponent(10, 1, 50, 1);
TestComponent c2 = new TestComponent(10, 1, 50, 1);
TestComponent c3 = new TestComponent(10, 1, 50, 1);
TestComponent c4 = new TestComponent(10, 1, 50, 1);
FormLayout layout = new FormLayout(
"10px, 15px, 20px:grow",
"pref, pref");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy (1, 1));
panel.add(c2, CC.xy (2, 1));
panel.add(c3, CC.xy (3, 1));
panel.add(c4, CC.xyw(1, 2, 2));
Dimension preferredLayoutSize = layout.preferredLayoutSize(panel);
panel.setSize(preferredLayoutSize);
panel.doLayout();
int col1And2Width = c2.getX() + c2.getWidth();
int gridWidth = c3.getX() + c3.getWidth();
int totalWidth = preferredLayoutSize.width;
assertEquals("Col1+2 width", 25, col1And2Width);
assertEquals("Grid width", 45, gridWidth);
assertEquals("Total width", 45, totalWidth); // 70 is wrong
}
示例8: testExtraExpansionIfSpannedColumnsGrow
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks and verifies that components that span multiple columns
* do not expand the container of no column grows.
*/
public static void testExtraExpansionIfSpannedColumnsGrow() {
TestComponent c1 = new TestComponent(10, 1, 50, 1);
TestComponent c2 = new TestComponent(10, 1, 50, 1);
TestComponent c3 = new TestComponent(10, 1, 50, 1);
TestComponent c4 = new TestComponent(10, 1, 50, 1);
FormLayout layout = new FormLayout(
"10px, 15px:grow, 20px",
"pref, pref");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy (1, 1));
panel.add(c2, CC.xy (2, 1));
panel.add(c3, CC.xy (3, 1));
panel.add(c4, CC.xyw(1, 2, 2));
Dimension preferredLayoutSize = layout.preferredLayoutSize(panel);
panel.setSize(preferredLayoutSize);
panel.doLayout();
int col1And2Width = c2.getX() + c2.getWidth();
int gridWidth = c3.getX() + c3.getWidth();
int totalWidth = preferredLayoutSize.width;
assertEquals("Col1+2 width", 50, col1And2Width);
assertEquals("Grid width", 70, gridWidth);
assertEquals("Total width", 70, totalWidth);
}
示例9: testDefaultSize
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Tests the layout size, column and row sizes for a default specs.
*/
public static void testDefaultSize() {
TestComponent c1 = new TestComponent(10, 10, 50, 50);
FormLayout layout = new FormLayout(
"default",
"default");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy(1, 1));
Dimension minimumLayoutSize = layout.minimumLayoutSize(panel);
Dimension preferredLayoutSize = layout.preferredLayoutSize(panel);
assertEquals("Minimum layout width", 10, minimumLayoutSize.width);
assertEquals("Minimum layout height", 10, minimumLayoutSize.height);
assertEquals("Preferred layout width", 50, preferredLayoutSize.width);
assertEquals("Preferred layout height", 50, preferredLayoutSize.height);
panel.setSize(minimumLayoutSize);
panel.doLayout();
int columnWidth = c1.getWidth();
int rowHeight = c1.getHeight();
assertEquals("Column width (container min)", 10, columnWidth);
assertEquals("Row height (container min)", 10, rowHeight);
panel.setSize(preferredLayoutSize);
panel.doLayout();
columnWidth = c1.getWidth();
rowHeight = c1.getHeight();
assertEquals("Column width (container pref)", 50, columnWidth);
assertEquals("Row height (container pref)", 50, rowHeight);
}
示例10: testDefaultWithLowerBound
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Tests the combination of a default size spec with a lower bound
* that shall ensure a minimum size.
*/
public static void testDefaultWithLowerBound() {
TestComponent c1 = new TestComponent(10, 10, 50, 50);
FormLayout layout = new FormLayout(
"[20px,default]",
"[20px,default]");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy(1, 1));
Dimension minimumLayoutSize = layout.minimumLayoutSize(panel);
Dimension preferredLayoutSize = layout.preferredLayoutSize(panel);
assertEquals("Minimum layout width", 20, minimumLayoutSize.width);
assertEquals("Minimum layout height", 20, minimumLayoutSize.height);
assertEquals("Preferred layout width", 50, preferredLayoutSize.width);
assertEquals("Preferred layout height", 50, preferredLayoutSize.height);
panel.setSize(minimumLayoutSize);
panel.doLayout();
int columnWidth = c1.getWidth();
int rowHeight = c1.getHeight();
assertEquals("Column width (container min)", 20, columnWidth);
assertEquals("Row height (container min)", 20, rowHeight);
panel.setSize(preferredLayoutSize);
panel.doLayout();
columnWidth = c1.getWidth();
rowHeight = c1.getHeight();
assertEquals("Column width (container pref)", 50, columnWidth);
assertEquals("Row height (container pref)", 50, rowHeight);
}
示例11: testDefaultWithUpperBound
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Tests the combination of a default size spec with an upper bound
* that shall ensure a maximum size.
*/
public static void testDefaultWithUpperBound() {
TestComponent c1 = new TestComponent(10, 10, 50, 50);
FormLayout layout = new FormLayout(
"[default,20px]",
"[default,20px]");
JPanel panel = new JPanel(layout);
panel.add(c1, CC.xy(1, 1));
Dimension minimumLayoutSize = layout.minimumLayoutSize(panel);
Dimension preferredLayoutSize = layout.preferredLayoutSize(panel);
assertEquals("Minimum layout width", 10, minimumLayoutSize.width);
assertEquals("Minimum layout height", 10, minimumLayoutSize.height);
assertEquals("Preferred layout width", 20, preferredLayoutSize.width);
assertEquals("Preferred layout height", 20, preferredLayoutSize.height);
panel.setSize(minimumLayoutSize);
panel.doLayout();
int columnWidth = c1.getWidth();
int rowHeight = c1.getHeight();
assertEquals("Column width (container min)", 10, columnWidth);
assertEquals("Row height (container min)", 10, rowHeight);
panel.setSize(preferredLayoutSize);
panel.doLayout();
columnWidth = c1.getWidth();
rowHeight = c1.getHeight();
assertEquals("Column width (container pref)", 20, columnWidth);
assertEquals("Row height (container pref)", 20, rowHeight);
}
示例12: createSamplePanel
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Creates and returns a sample panel that uses the sample layout
* created by {@code #createSampleLayout}. Useful to test the
* FormLayout serialization in combination with a layout container
* and some components managed by the FormLayout. Especially it tests
* the serialization of {@code CellConstraints} objects.
*
* @return a sample panel
*/
private static JPanel createSamplePanel() {
JPanel panel = new JPanel(createSampleLayout());
panel.add(new JLabel("Test1"), CC.xy(1, 1, "l, t"));
panel.add(new JButton("Test2"), CC.xy(2, 2, "c, c"));
panel.add(new JButton("Test3"), CC.xy(3, 3, "r, b"));
panel.add(new JButton("Test4"), CC.xy(4, 4, "f, f"));
panel.doLayout();
return panel;
}
示例13: testLabelForWithMnemonic
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks the association between mnemonic label and next component.
*/
public void testLabelForWithMnemonic() {
builder.add(labelWithMnemonic, CC.xy(1, 1));
builder.add(plainField, CC.xy(3, 1));
assertSame("Labeling label",
plainField,
labelWithMnemonic.getLabelFor());
}
示例14: testLabelForWithoutMnemonic
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks the association between plain label and next component.
*/
public void testLabelForWithoutMnemonic() {
builder.add(labelWithoutMnemonic, CC.xy(1, 1));
builder.add(plainField, CC.xy(3, 1));
assertSame("Labeling label",
plainField,
labelWithoutMnemonic.getLabelFor());
}
示例15: testLabelForUnfocusableField
import com.jgoodies.forms.factories.CC; //导入依赖的package包/类
/**
* Checks the association between label and unfocusable component.
*/
public void testLabelForUnfocusableField() {
builder.add(labelWithoutMnemonic, CC.xy(1, 1));
builder.add(unfocusableField, CC.xy(3, 1));
assertNull("Labeling label",
labelWithoutMnemonic.getLabelFor());
}