本文整理汇总了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;
}
示例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);
}