java初学者
所有生命,不管在哪里度过,都具有同样价值
posts - 7,  comments - 5,  trackbacks - 0
import javax.swing.*;
import java.awt.*;
public class GridLayoutDemo extends JFrame{
public GridLayoutDemo()
 {
 super("网格布局");
 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 悠扬---靖宝华 阅读(293) | 评论 (0)编辑 收藏

/*class Rectangle
{//实例变量
 private double width;//类成员的访问控制,不允许对象通过点符号,来直接访问该变量,
 private double height;
 //方法
 public double Area()         //返回值类型 方法名字(){具体的实现语句;}
  {return width*height;} //求矩形面积
 public double Perimeter()
  {return 2*(width+height);}//求矩形周长

//构造函数

  public Rectangle(double width,double height) //用于变量的赋初值,
   {
   this.width=width;
   this.height=height;//this关键字用于构造函数参数与实例变量名字相同时候.
   }
}

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 悠扬---靖宝华 阅读(246) | 评论 (0)编辑 收藏

<2006年10月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(1)

随笔档案(7)

搜索

  •  

最新评论

阅读排行榜

评论排行榜