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


Java JButton.setLayout方法代码示例

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


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

示例1: getContributeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public JButton getContributeButton() {
	JButton contributeB = new JButton();
	contributeB.setLayout(new BorderLayout());
	JLabel label1 = new JLabel("Contribute");
	JLabel label2 = new JLabel("Data");
	label1.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.add(BorderLayout.CENTER,label1);
	label2.setFont(new Font("Arial", Font.BOLD, 11));
	label2.setHorizontalAlignment(SwingConstants.CENTER);
	contributeB.add(BorderLayout.SOUTH,label2);
	contributeB.setSize(new Dimension(115, 30));
	contributeB.setMargin(new Insets(0, 0, 0, 0));
	contributeB.setBackground(new Color( 224, 224, 224)); ;
	contributeB.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.setHorizontalAlignment(SwingConstants.LEFT);
	
	return contributeB;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:19,代码来源:MapTools.java

示例2: removeNotify

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void removeNotify() {
    super.removeNotify();
    
    removeAll();
    for (JButton jb : buttons) {
        if (jb != null) jb.setLayout(null);
    }
    buttons.clear();            
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:14,代码来源:NewUnitPanel.java

示例3: update

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Updates this panel's labels so that the information it displays
 * is up to date.
 */
public final void update() {
    removeAll();

    final Player player = getMyPlayer();
    final Europe europe = player.getEurope();

    add(question, "span, wrap 20");

    // The prices may have changed, recreate the buttons
    buttons.clear();
    for (UnitType ut : sort(units, priceComparator)) {
        int price = europe.getUnitPrice(ut);
        boolean enable = player.checkGold(price);
        JButton newButton = new JButton();
        newButton.setLayout(new MigLayout("wrap 2", "[60]", "[30][30]"));
        ImageIcon icon = new ImageIcon(getImageLibrary().getSmallUnitImage(
            ut, !enable));
        JLabel name = Utility.localizedLabel(ut);
        name.setEnabled(enable);
        JLabel gold = Utility.localizedLabel(StringTemplate
            .template("goldAmount")
            .addAmount("%amount%", price));
        gold.setEnabled(enable);
        newButton.setEnabled(enable);
        newButton.add(new JLabel(icon), "span 1 2");
        newButton.add(name);
        newButton.add(gold);
        newButton.setActionCommand(ut.getId());
        newButton.addActionListener(this);
        buttons.add(newButton);
        add(newButton, "grow");
    }

    add(okButton, "newline 20, span, tag ok");

    setSize(getPreferredSize());
    revalidate();

    shouldEnable = player.checkGold(europe.getUnitPrice(first(units)));
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:45,代码来源:NewUnitPanel.java


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