当前位置: 代码迷 >> J2SE >> 布局设计的GridLayout,该如何解决
  详细解决方案

布局设计的GridLayout,该如何解决

热度:1532   发布时间:2013-02-25 21:55:32.0
布局设计的GridLayout
import javax.swing.*;
import java.awt.*; 
public class TestGridLayout{
public static void main(String args[]){
        JFrame win=new JFrame("窗体"); 
        win.setBounds(200,200,600,600);
        win.setVisible(true);
        JButton bSouth=new JButton("南"),
               bNorth=new JButton("北"),
               bEast =new JButton("东"),
               bWest =new JButton("西");
        JPanel bCenter=new JPanel();
        
        win.add(bNorth,BorderLayout.NORTH);
        win.add(bSouth,BorderLayout.SOUTH);
        win.add(bEast,BorderLayout.EAST);
        win.add(bWest,BorderLayout.WEST); 
        win.add( bCenter,BorderLayout.CENTER);
        
        JButton b[];      
        bCenter.setLayout(new Gridlayout(3,3,5,5));//一直在这报错java.awt.Gridlayout cannot be resolved to a type

        b=new JButton[9];
        for(int i=0;i<b.length;i++){
         b[i]=new JButton(""+i);
          bCenter.add(b[i]);
        }
      
        win.validate();
        win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
求高手解决,,,,,
引用:
new Gridlayout(3,3,5,5));
你这里3  3  5  5指的是什么?
改成
GridLayout(3, 5);试试


这不知道就查一下 API不就懂了么