import javax.swing.*;
import java.awt.*;
public class GridLayoutDemo extends JFrame{
public GridLayoutDemo()
{
?super("網(wǎng)格布局");
?this.setSize(600,300);
?this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setlayout(){
?FlowLayout layout = new FlowLayout();
?Container Contain = getContentPane();
?Contain.setLayout(layout);
?for(int i=1; i<6;i++)
{
?JButton btn = new JButton("按鈕"+i);
?Contain.add(btn);
?}
}
public static void main(String []args )
{
?GridLayoutDemo GridLay = new GridLayoutDemo();
?GridLay.setlayout();
?GridLay.show();
}
}
posted @
2006-12-21 20:04 悠揚---靖寶華 閱讀(303) |
評論 (0) |
編輯 收藏
/*class Rectangle
{//實例變量
?private double width;//類成員的訪問控制,不允許對象通過點符號,來直接訪問該變量,
?private double height;
?//方法
?public double Area()???????? //返回值類型 方法名字(){具體的實現(xiàn)語句;}
? {return width*height;} //求矩形面積
?public?double Perimeter()
? {return 2*(width+height);}//求矩形周長
//構(gòu)造函數(shù)
? public Rectangle(double width,double height) //用于變量的賦初值,
?? {
?? this.width=width;
?? this.height=height;//this關(guān)鍵字用于構(gòu)造函數(shù)參數(shù)與實例變量名字相同時候.
?? }
}
public class RectangleDemo
{
?public static void main(String [] args)
?{
??Rectangle rectangle1=new Rectangle(4,5); //矩形長寬賦值,
??System.out.println("矩形的面積是"+rectangle1.Area());
??System.out.println("矩形的面積是"+rectangle1.Perimeter());?
?}
}*/
posted @
2006-10-20 21:02 悠揚---靖寶華 閱讀(258) |
評論 (0) |
編輯 收藏