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


Java BoxLayout.X_AXIS属性代码示例

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


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

示例1: MainToolBar

MainToolBar(@NonNull final Pair<JComponent,GridBagConstraints>... components) {
    super(BoxLayout.X_AXIS);
    setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 5));
    final JToolBar toolbar = new NoBorderToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setBorderPainted(false);
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setOpaque(false);
    toolbar.setFocusable(false);
    toolbar.setLayout(new GridBagLayout());
    for (Pair<JComponent,GridBagConstraints> p : components) {
        toolbar.add(p.first(),p.second());
    }
    add (toolbar);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HierarchyTopComponent.java

示例2: setOrientation

public void setOrientation(Object value) {
	int axis;
	String position;
	if (value == HORIZONTAL) {
		axis = BoxLayout.X_AXIS;
		position = BorderLayout.LINE_START;
	} else if (value == VERTICAL) {
		axis = BoxLayout.Y_AXIS;
		position = BorderLayout.NORTH;
	} else {
		throw new IllegalArgumentException();
	}
	this.remove(subpanel);
	subpanel.setLayout(new BoxLayout(subpanel, axis));
	this.add(subpanel, position);
	this.orientation = value;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:Toolbar.java

示例3: getNewIndex

/** This method calculates position (index) for a component dragged
 * over a container (or just for mouse cursor being moved over container,
 * without any component).
 * @param container instance of a real container over/in which the
 *        component is dragged
 * @param containerDelegate effective container delegate of the container
 *        (for layout managers we always use container delegate instead of
 *        the container)
 * @param component the real component being dragged; not needed here
 * @param index position (index) of the component in its current container;
 *        not needed here
 * @param posInCont position of mouse in the container delegate
 * @param posInComp position of mouse in the dragged component;
 *        not needed here
 * @return index corresponding to the position of the component in the
 *         container
 */
@Override
public int getNewIndex(Container container,
                       Container containerDelegate,
                       Component component,
                       int index,
                       Point posInCont,
                       Point posInComp)
{
    if (!(containerDelegate.getLayout() instanceof BoxLayout))
        return -1;
    
    assistantParams = 0;
    Component[] components = containerDelegate.getComponents();
    for (int i = 0; i < components.length; i++) {
        if (components[i] == component) {
            assistantParams--;
            continue;
        }
        Rectangle b = components[i].getBounds();
        if ((axis == BoxLayout.X_AXIS) || (axis == BoxLayout.LINE_AXIS)) {
            if (posInCont.x < b.x + b.width / 2) {
                assistantParams += i;
                return i;
            }
        }
        else {
            if (posInCont.y < b.y + b.height / 2) {
                assistantParams += i;
                return i;
            }
        }
    }
    
    assistantParams += components.length;
    return components.length;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:BoxLayoutSupport.java

示例4: FiltersComponent

/** Not public, instances created using factory method createPanel */
FiltersComponent(FiltersDescription descr) {
    super(BoxLayout.X_AXIS);
    this.filtersDesc = descr;
    // always create swing content in AWT thread
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable () {
            public void run () {
                initPanel();                        
            }
        });
    } else {
        initPanel();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FiltersManager.java

示例5: FiltersComponent

/** Not public, instances created using factory method createPanel */
FiltersComponent(FiltersDescription descr) {
    super(BoxLayout.X_AXIS);
    this.filtersDesc = descr;
    // always create swing content in AWT thread
    Mutex.EVENT.readAccess(new Runnable () {
        public void run () {
            initPanel();                        
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:FiltersManager.java

示例6: getLayout

private LayoutManager getLayout(Container c) {
  if (fixed) {
    return new GridLayout(0, nColumns);
  }
  else {
    return new BoxLayout(c, vertical ? BoxLayout.Y_AXIS : BoxLayout.X_AXIS);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:8,代码来源:PanelWidget.java

示例7: QueryColorChooser

public QueryColorChooser(
    String name,
    String defaultColor) {

    super(BoxLayout.X_AXIS);
    _defaultColor = defaultColor;
    _entryBox = new JTextField(defaultColor, _width);
    JButton button = new JButton("Choose");
    button.addActionListener(this);
    add(_entryBox);
    add(button);
    // Add the listener last so that there is no notification
    // of the first value.
    _entryBox.addActionListener(new QueryActionListener(name));

    // Add a listener for loss of focus.  When the entry gains
    // and then loses focus, listeners are notified of an update,
    // but only if the value has changed since the last notification.
    // FIXME: Unfortunately, Java calls this listener some random
    // time after the window has been closed.  It is not even a
    // a queued event when the window is closed.  Thus, we have
    // a subtle bug where if you enter a value in a line, do not
    // hit return, and then click on the X to close the window,
    // the value is restored to the original, and then sometime
    // later, the focus is lost and the entered value becomes
    // the value of the parameter.  I don't know of any workaround.
    _entryBox.addFocusListener(new QueryFocusListener(name));

    _name = name;
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:30,代码来源:Query.java

示例8: QueryFileChooser

public QueryFileChooser(
        String name,
        String defaultName,
        URI base,
        File startingDirectory,
        Color background) {
    super(BoxLayout.X_AXIS);
    _base = base;
    _startingDirectory = startingDirectory;
    _entryBox = new JTextField(defaultName, _width);
    _entryBox.setBackground(background);
    JButton button = new JButton("Browse");
    button.addActionListener(this);
    add(_entryBox);
    add(button);
    // Add the listener last so that there is no notification
    // of the first value.
    _entryBox.addActionListener(new QueryActionListener(name));

    // Add a listener for loss of focus.  When the entry gains
    // and then loses focus, listeners are notified of an update,
    // but only if the value has changed since the last notification.
    // FIXME: Unfortunately, Java calls this listener some random
    // time after the window has been closed.  It is not even a
    // a queued event when the window is closed.  Thus, we have
    // a subtle bug where if you enter a value in a line, do not
    // hit return, and then click on the X to close the window,
    // the value is restored to the original, and then sometime
    // later, the focus is lost and the entered value becomes
    // the value of the parameter.  I don't know of any workaround.
    _entryBox.addFocusListener(new QueryFocusListener(name));

    _name = name;
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:34,代码来源:Query.java

示例9: IntlOptions

public IntlOptions(PreferencesFrame window) {
	super(window);
	locale = Strings.createLocaleSelector();
	replAccents = new PrefBoolean(AppPreferences.ACCENTS_REPLACE, Strings.getter("intlReplaceAccents"));
	gateShape = new PrefOptionList(AppPreferences.GATE_SHAPE, Strings.getter("intlGateShape"),
			new PrefOption[] { new PrefOption(AppPreferences.SHAPE_SHAPED, Strings.getter("shapeShaped")),
					new PrefOption(AppPreferences.SHAPE_RECTANGULAR, Strings.getter("shapeRectangular")),
					new PrefOption(AppPreferences.SHAPE_DIN40700, Strings.getter("shapeDIN40700")) });

	Box localePanel = new Box(BoxLayout.X_AXIS);
	localePanel.add(Box.createGlue());
	localePanel.add(localeLabel);
	localeLabel.setMaximumSize(localeLabel.getPreferredSize());
	localeLabel.setAlignmentY(Component.TOP_ALIGNMENT);
	localePanel.add(locale);
	locale.setAlignmentY(Component.TOP_ALIGNMENT);
	localePanel.add(Box.createGlue());

	JPanel shapePanel = new JPanel();
	shapePanel.add(gateShape.getJLabel());
	shapePanel.add(gateShape.getJComboBox());

	setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
	add(Box.createGlue());
	add(shapePanel);
	add(localePanel);
	add(replAccents);
	add(Box.createGlue());
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:29,代码来源:IntlOptions.java

示例10: getProperties

/** Since BoxLayout is not a bean, we must specify its properties
     * explicitly. This method is called from getPropertySets() implementation
     * to obtain the default property set for the layout (assuming there's only
     * one property set). So it woul be also possible to override (more
     * generally) getPropertySets() instead.
     * @return array of properties of the layout manager
     */
    @Override
    protected FormProperty[] getProperties() {
        if (properties == null) {
            // we cannot use RADProperty because "axis" is not a real
            // bean property - we must create a special FormProperty
            properties = new FormProperty[1];

            properties[0] = new FormProperty(
                                PROP_AXIS,
                                Integer.TYPE,
                                getBundle().getString("PROP_axis"), // NOI18N
                                getBundle().getString("HINT_axis")) // NOI18N
            {
                @Override
                public Object getTargetValue() {
                    return new Integer(axis);
                }

                @Override
                public void setTargetValue(Object value) {
                    int ax = ((Integer)value).intValue();
                    if (ax == BoxLayout.X_AXIS || ax == BoxLayout.Y_AXIS
                            || ax == BoxLayout.LINE_AXIS || ax == BoxLayout.PAGE_AXIS) {
                        axis = ax;
                    }
                }

                @Override
                public boolean supportsDefaultValue() {
                    return true;
                }

                @Override
                public Object getDefaultValue() {
                    return new Integer(BoxLayout.LINE_AXIS);
                }

                @Override
                public PropertyEditor getExpliciteEditor() {
                    return new BoxAxisEditor();
                }
            };
            // [!!]
//            properties[0].setPropertyContext(
//                new FormPropertyContext.DefaultImpl(getContainer().getFormModel()));
        }

        return properties;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:BoxLayoutSupport.java

示例11: CustomToolbar

public CustomToolbar() {
    super(BoxLayout.X_AXIS);
    initPanel();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:CustomToolbar.java

示例12: createInstanceImpl

protected Box createInstanceImpl() {
    return new Box(BoxLayout.X_AXIS) {
        public void layout() {}
        public void setLayout(LayoutManager l) {}
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:JComponentBuilders.java

示例13: constructJComponent

/** Constructs panel containing the main GUI components. */
private JPanel constructJComponent() {

	// Selection panel

	BoxLayout selectionPanelLayout = new BoxLayout(selectionPanel, BoxLayout.Y_AXIS);
	selectionPanel.setLayout(selectionPanelLayout);
	ButtonGroup radioButtons = new ButtonGroup();
	if (optionsToSelect != null) {
		for (int i = 0; i < optionsToSelect.size(); i++) {
			JRadioButton radioButton = new JRadioButton(getI18n(optionsToSelect.get(i)));
			radioButton.setHorizontalAlignment(JRadioButton.LEFT);
			if (i == 0) {
				radioButton.setSelected(true);
			}
			radioButtons.add(radioButton);
			selectionPanel.add(radioButton);
		}
	}

	// Checkbox panel

	BoxLayout checkboxPanelLayout = new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS);
	checkboxPanel.setLayout(checkboxPanelLayout);
	if (optionsToCheck != null) {
		for (int i = 0; i < optionsToCheck.size(); i++) {
			JCheckBox jCheckBox = new JCheckBox(getI18n(optionsToCheck.get(i)));
			jCheckBox.setHorizontalAlignment(JCheckBox.LEFT);
			checkboxPanel.add(jCheckBox);
		}
	}

	// Overall panel

	JPanel panel = new JPanel();
	BoxLayout panelLayout = new BoxLayout(panel, BoxLayout.Y_AXIS);
	panel.setLayout(panelLayout);
	panel.add(selectionPanel);
	if (optionsToSelect != null && !optionsToSelect.isEmpty() && optionsToCheck != null || !optionsToCheck.isEmpty()) {
		panel.add(Box.createRigidArea(new Dimension(0, GAP_BETWEEN_SELECTIONS)));
	}
	panel.add(checkboxPanel);

	JPanel leftMarginPanel = new JPanel();
	BoxLayout leftMarginPanelLayout = new BoxLayout(leftMarginPanel, BoxLayout.X_AXIS);
	leftMarginPanel.setLayout(leftMarginPanelLayout);
	leftMarginPanel.add(Box.createRigidArea(new Dimension(getInfoIcon().getIconWidth() + BUTTON_DIALOG_LEFT_GAP, 0)));
	leftMarginPanel.add(panel);

	return leftMarginPanel;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:51,代码来源:SelectionDialog.java

示例14: getBoxLayout

private BoxLayout getBoxLayout() {
    boxLayout = new BoxLayout(getJPanel2(), BoxLayout.X_AXIS);
    return boxLayout;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:4,代码来源:IDEFPanel.java

示例15: initComponents

/**
 * This method initializes the components for the wizard dialog: it creates a JDialog
 * as a CardLayout panel surrounded by a small amount of space on each side, as well
 * as three buttons at the bottom.
 */

private void initComponents() {

    wizardModel.addPropertyChangeListener(this);       
    wizardController = new WizardController(this);       

    wizardDialog.getContentPane().setLayout(new BorderLayout());
    wizardDialog.addWindowListener(this);
            
    //  Create the outer wizard panel, which is responsible for three buttons:
    //  Next, Back, and Cancel. It is also responsible a JPanel above them that
    //  uses a CardLayout layout manager to display multiple panels in the 
    //  same spot.
    
    JPanel buttonPanel = new JPanel();
    JSeparator separator = new JSeparator();
    Box buttonBox = new Box(BoxLayout.X_AXIS);

    cardPanel = new JPanel();
    cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));       

    cardLayout = new CardLayout(); 
    cardPanel.setLayout(cardLayout);
    
    backButton = new JButton(new ImageIcon("com/nexes/wizard/backIcon.gif"));
    nextButton = new JButton();
    cancelButton = new JButton();
    
    backButton.setActionCommand(BACK_BUTTON_ACTION_COMMAND);
    nextButton.setActionCommand(NEXT_BUTTON_ACTION_COMMAND);
    cancelButton.setActionCommand(CANCEL_BUTTON_ACTION_COMMAND);

    backButton.addActionListener(wizardController);
    nextButton.addActionListener(wizardController);
    cancelButton.addActionListener(wizardController);
    
    //  Create the buttons with a separator above them, then place them
    //  on the east side of the panel with a small amount of space between
    //  the back and the next button, and a larger amount of space between
    //  the next button and the cancel button.
    
    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.add(separator, BorderLayout.NORTH);

    buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));       
    buttonBox.add(backButton);
    buttonBox.add(Box.createHorizontalStrut(10));
    buttonBox.add(nextButton);
    buttonBox.add(Box.createHorizontalStrut(30));
    buttonBox.add(cancelButton);
    
    buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST);
    
    wizardDialog.getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
    wizardDialog.getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER);

}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:62,代码来源:Wizard.java


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