正在加载图片...
下面的程序创建了一个小的黄色面板,并将它加到一个框架对象上 1. import java. awt. *i 2. public class FrameWith Panel extends Frame t / Cons truc public Frame With anel (String str) i super (str)i 67891111 public static void main (String args [])i FramewithPanel fr new FrameWithPanel (Frame with Panel") Panel pan new Panel()i fr setsize(200, 200)i fr setBackground Color blue) fr. setLayout (null);//override default la yout mgr pan setsize (100, 100)i pan setBackground( Color yellow) fr. add(pan)i fr setvisible(true)i xd Frame with Panel 第八节容器布局( Container Layout 容器布局( Container Layout)108 下面的程序创建了一个小的黄色面板,并将它加到一个框架对象上: 1. import java.awt.*; 2. public class FrameWithPanel extends Frame { 3. 4. // Constructor 5. public FrameWithPanel (String str) { 6. super (str); 7. } 8. 9. public static void main (String args[]) { 10. FrameWithPanel fr = 11. new FrameWithPanel ("Frame with Panel"); 12. Panel pan = new Panel(); 13. 14. fr.setSize(200,200); 15. fr.setBackground(Color.blue); 16. fr.setLayout(null); //override default layout mgr 17. pan.setSize (100,100); 18. pan.setBackground(Color.yellow); 19. 20. fr.add(pan); 21. fr.setVisible(true); 22. } 23. .... 24. 第八节 容器布局(Container Layout) 容器布局(Container Layout) - 流程布局(Flow Layout)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有