本文整理匯總了Java中java.awt.GridBagConstraints.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java GridBagConstraints.clone方法的具體用法?Java GridBagConstraints.clone怎麽用?Java GridBagConstraints.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.GridBagConstraints
的用法示例。
在下文中一共展示了GridBagConstraints.clone方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addLabeledComponentToGBL
import java.awt.GridBagConstraints; //導入方法依賴的package包/類
private void addLabeledComponentToGBL( String name,
JComponent c,
GridBagLayout gbl,
GridBagConstraints gbc,
Container target ) {
LabelV2 l = new LabelV2( name );
GridBagConstraints gbcLabel = (GridBagConstraints) gbc.clone();
gbcLabel.insets = new Insets( 2, 2, 2, 0 );
gbcLabel.gridwidth = 1;
gbcLabel.weightx = 0;
if ( c == null )
c = new JLabel( "" );
gbl.setConstraints( l, gbcLabel );
target.add( l );
gbl.setConstraints( c, gbc );
target.add( c );
}
示例2: makeGrid
import java.awt.GridBagConstraints; //導入方法依賴的package包/類
public static JPanel makeGrid(int cols, GridBagConstraints template, Container... containers) {
JPanel ans = new JPanel(new GridBagLayout());
int i = -1;
for (Container container : containers) {
for (Component comp : container.getComponents()) {
i++;
GridBagConstraints c = (GridBagConstraints) template.clone();
c.gridx = i % cols;
c.gridy = i / cols;
ans.add(comp, c);
}
}
return ans;
}