本文整理匯總了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;
}
示例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();
}
示例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)));
}