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


Java GridBagLayout.addLayoutComponent方法代码示例

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


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

示例1: createCatalogPanel

import java.awt.GridBagLayout; //导入方法依赖的package包/类
private JPanel createCatalogPanel() {
	JPanel selector = new JPanel();

	Icon expandedIcon = new ArrowIcon(ArrowIcon.SOUTH, UIManager.getColor(Guitilities.TITLE_FOREGROUND));
	Icon collapsedIcon = new ArrowIcon(ArrowIcon.EAST, UIManager.getColor(Guitilities.TITLE_FOREGROUND));

	GridBagLayout gridbag = new GridBagLayout();
	selector.setLayout(gridbag);
	GridBagConstraints constraints = new GridBagConstraints();
	constraints.gridx = constraints.gridy = 0; constraints.weightx = 1;
	constraints.fill = GridBagConstraints.HORIZONTAL;

	GridBagConstraints categoryConstraints = new GridBagConstraints();
	categoryConstraints.gridx = categoryConstraints.gridy = 0; categoryConstraints.weightx = 1;
	categoryConstraints.fill = GridBagConstraints.HORIZONTAL;

	CollapsiblePanel collapsible;
	for(Entry<String, HashMap<ComponentAttributes, Class<? extends Component>>> group_entry:componentGroups.entrySet()) {
		JPanel category = new JPanel();
		GridBagLayout categoryGridbag = new GridBagLayout();
		category.setLayout(categoryGridbag);

		collapsible = new CollapsiblePanel(category, getTranslation(group_entry.getKey()), getTranslation("group.expand"));
		collapsible.setBorder(Guitilities.CATEGORY_BORDER);
		collapsible.setFont(UIManager.getFont("CheckBox.font").deriveFont(Font.BOLD));
		collapsible.setForeground(UIManager.getColor(Guitilities.TITLE_FOREGROUND));
		collapsible.setExpandedIcon(expandedIcon);
		collapsible.setCollapsedIcon(collapsedIcon);
		collapsible.setExpanded(false);
		collapsiblePanels.add(collapsible);

		gridbag.addLayoutComponent(collapsible, constraints);
		selector.add(collapsible);
		constraints.gridy++;

		for(Entry<ComponentAttributes, Class<? extends Component>> entry:group_entry.getValue().entrySet())
			try {
				ComponentButton button = new ComponentButton(entry.getKey(), entry.getValue());
				categoryGridbag.addLayoutComponent(button, categoryConstraints);
				categoryConstraints.gridy++;
				category.add(button);
				componentButtons.add(button);
			} catch (Exception e) { e.printStackTrace(); }
	}

	JPanel trailer = new JPanel();
	constraints.weighty = 1.0;
	gridbag.addLayoutComponent(trailer, constraints);
	selector.add(trailer);

	return selector;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:53,代码来源:Application.java

示例2: update

import java.awt.GridBagLayout; //导入方法依赖的package包/类
private static void update(GridBagLayout layout, String id, int x, int y) {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = x;
    gbc.gridy = y;
    layout.addLayoutComponent(new JLabel(id), gbc);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:java_awt_GridBagLayout.java


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