當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。