本文整理匯總了Java中java.awt.Panel.setBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java Panel.setBounds方法的具體用法?Java Panel.setBounds怎麽用?Java Panel.setBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Panel
的用法示例。
在下文中一共展示了Panel.setBounds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ComponentIsNotDrawnAfterRemoveAddTest
import java.awt.Panel; //導入方法依賴的package包/類
public ComponentIsNotDrawnAfterRemoveAddTest() {
frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest");
frame.setSize(500, 500);
frame.setLocation(200, 200);
frame.setLayout(null);
frame.setBackground(Color.RED);
panel = new Panel();
panel.setLayout(null);
panel.setBounds(25, 100, 455, 295);
panel.setBackground(Color.GREEN);
for (int i = 0; i < 10; i++) {
TestCanvas canv1 = new TestCanvas();
canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i);
panel.add(canv1);
compList.add(canv1);
TestButton btn1 = new TestButton();
btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i);
panel.add(btn1);
compList.add(btn1);
TestCanvas canv2 = new TestCanvas();
canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i);
panel.add(canv2);
compList.add(canv2);
TestButton btn2 = new TestButton();
btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i);
panel.add(btn2);
compList.add(btn2);
TestCanvas canv3 = new TestCanvas();
canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i);
panel.add(canv3);
compList.add(canv3);
TestButton btn3 = new TestButton();
btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i);
panel.add(btn3);
compList.add(btn3);
}
frame.add(panel);
frame.setVisible(true);
}