Java Code Examples for javax.swing.JComponent#setAlignmentY()

The following examples show how to use javax.swing.JComponent#setAlignmentY() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netbeans   File: EmptyTestStepLocation.java    License: Apache License 2.0 5 votes vote down vote up
private Component createVisualComp() {
    JCheckBox[] chkBoxes;
    
    JComponent optCode = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptCode"),               //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_SETUP,
                    GuiUtils.CHK_TEARDOWN,
                    GuiUtils.CHK_BEFORE_CLASS,
                    GuiUtils.CHK_AFTER_CLASS}));
    chkSetUp = chkBoxes[0];
    chkTearDown = chkBoxes[1];
    chkBeforeClass = chkBoxes[2];
    chkAfterClass = chkBoxes[3];
    
    JComponent optComments = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptComments"),           //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_HINTS}));
    chkCodeHints = chkBoxes[0];

    JComponent box = new SelfResizingPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(optCode);
    box.add(Box.createHorizontalStrut(18));
    box.add(optComments);

    /* tune layout of the components within the box: */
    optCode.setAlignmentY(0.0f);
    optComments.setAlignmentY(0.0f);

    return box;
}
 
Example 2
private void addOptions(Tab tab) {
    JPanel optionsContainer = new JPanel();
    optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.X_AXIS));
    optionsContainer.setOpaque(false);

    JComponent[] options = tab.getOptions();
    if (options != null) for (JComponent option : options) {
        option.setBorder(BorderFactory.createEmptyBorder(3, 5, 2, DisplayAreaSupport.TABBUTTON_MARGIN_RIGHT));
        option.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        optionsContainer.add(option);
    }

    tabsMapper.put(tab, optionsContainer);
    contentsPanel.add(optionsContainer, tab.getName());
}
 
Example 3
Source Project: netbeans   File: TestSuiteStepLocation.java    License: Apache License 2.0 4 votes vote down vote up
private Component createVisualComp() {
    JCheckBox[] chkBoxes;
    
    JComponent infoLabel = GuiUtils.createMultilineLabel(
            NbBundle.getMessage(TestSuiteStepLocation.class,
                                "TXT_ClassesInSuite"));             //NOI18N
    JComponent optCode = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptCode"),               //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_SETUP,
                    GuiUtils.CHK_TEARDOWN,
                    GuiUtils.CHK_BEFORE_CLASS,
                    GuiUtils.CHK_AFTER_CLASS}));
    chkSetUp = chkBoxes[0];
    chkTearDown = chkBoxes[1];
    chkBeforeClass = chkBoxes[2];
    chkAfterClass = chkBoxes[3];
    
    JComponent optComments = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptComments"),           //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_HINTS}));
    chkCodeHints = chkBoxes[0];

    JComponent bottomPanel = new SelfResizingPanel();
    bottomPanel.setLayout(new BorderLayout(0, 24));
    bottomPanel.add(infoLabel, BorderLayout.NORTH);
    JComponent box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(optCode);
    box.add(Box.createHorizontalStrut(18));
    box.add(optComments);
    bottomPanel.add(box, BorderLayout.CENTER);
    
    /* tune layout of the components within the box: */
    infoLabel.setAlignmentX(0.0f);
    optCode.setAlignmentY(0.0f);
    optComments.setAlignmentY(0.0f);
 
    return bottomPanel;
}
 
Example 4
Source Project: stendhal   File: Character.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create the content layout and add the ItemPanels.
 */
private void createLayout() {
	// Layout containers
	JComponent content = SBoxLayout.createContainer(SBoxLayout.VERTICAL, PADDING);
	JComponent row = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, PADDING);
	JComponent left = SBoxLayout.createContainer(SBoxLayout.VERTICAL, PADDING);
	JComponent middle = SBoxLayout.createContainer(SBoxLayout.VERTICAL, PADDING);
	JComponent right = SBoxLayout.createContainer(SBoxLayout.VERTICAL, PADDING);
	left.setAlignmentY(CENTER_ALIGNMENT);
	right.setAlignmentY(CENTER_ALIGNMENT);
	row.add(left);
	row.add(middle);
	row.add(right);
	content.add(row);

	Class<? extends IEntity> itemClass = EntityMap.getClass("item", null, null);
	SpriteStore store = SpriteStore.get();

	/*
	 * Fill the left column
	 *
	 * Add filler to shift the hand slots down. Shift * 2 because centering
	 * the column uses the other half at the bottom.
	 */
	left.add(Box.createVerticalStrut(HAND_YSHIFT * 2));

	ItemPanel panel = createItemPanel(itemClass, store, "rhand", "data/gui/weapon-slot.png");
	left.add(panel);
	panel = createItemPanel(itemClass, store, "finger", "data/gui/ring-slot.png");
	left.add(panel);

	// Fill the middle column
	panel = createItemPanel(itemClass, store, "head", "data/gui/helmet-slot.png");
	middle.add(panel);
	panel = createItemPanel(itemClass, store, "armor", "data/gui/armor-slot.png");
	middle.add(panel);
	panel = createItemPanel(itemClass, store, "legs", "data/gui/legs-slot.png");
	middle.add(panel);
	panel = createItemPanel(itemClass, store, "feet", "data/gui/boots-slot.png");
	middle.add(panel);

	/*
	 *  Fill the right column
	 *
	 * Add filler to shift the hand slots down. Shift * 2 because centering
	 * the column uses the other half at the bottom.
	 */
	right.add(Box.createVerticalStrut(HAND_YSHIFT * 2));
	panel = createItemPanel(itemClass, store, "lhand", "data/gui/shield-slot.png");
	right.add(panel);
	panel = createItemPanel(itemClass, store, "cloak", "data/gui/cloak-slot.png");

	right.add(panel);

	// Bag, keyring, etc
	specialSlots = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, PADDING);
	specialSlots.setAlignmentX(CENTER_ALIGNMENT);
	// Compatibility. See the note at setPlayer().
	specialSlots.setVisible(false);
	content.add(specialSlots);

	panel = createItemPanel(itemClass, store, "back", "data/gui/bag-slot.png");
	specialSlots.add(panel);
	panel = createItemPanel(itemClass, store, "belt", "data/gui/key-slot.png");
	specialSlots.add(panel);

	setContent(content);
}
 
Example 5
Source Project: shakey   File: VerticalPanel.java    License: Apache License 2.0 4 votes vote down vote up
public void add(JComponent comp) {
	comp.setAlignmentY(0);
	super.add( comp);
}