panel挡住菜单栏
如下程序片断,菜单被panel挡住,显示不出来,去掉panel就没问题了,会是什么问题呢? import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import *;
public class SaoLei extends JFrame implements ActionListener {
JButton [][] Mine=new JButton[8][8];
JButton Start=new JButton();
Container Con=this.getContentPane();
Panel P1;
JMenuBar mb;
JMenu m1,m2;
JMenuItem MI1,MI2,MI3,MI4,MI5;
public SaoLei() {
Start=new JButton("开始");
Start.setSize(200,200);
mb=new JMenuBar();
m1=new JMenu("文件");
m2=new JMenu("选项");
MI1= new JMenuItem("开始");
MI2= new JMenuItem("结束");
MI3= new JMenuItem("退出");
MI4= new JMenuItem("历史记录");
MI5= new JMenuItem("帮助");
P1=new Panel();
P1.setLayout(new GridLayout(8,8));
P1.set
for(int i=0;i<8;i++)
for(int j=0;j<8;j++)
{
Mine[i][j]=new JButton();
P1.add(Mine[i][j]);
}
Con.setLayout(new BorderLayout());
mb.add(m1);
mb.add(m2);
m1.add(MI1);
m1.add(MI2);
m1.addSeparator();
m1.add(MI3);
m2.add(MI4);
m2.add(MI5);
Con.add(Start,BorderLayout.NORTH);
Con.add(P1,BorderLayout.CENTER);
this.setJMenuBar(mb);
pack();
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
}
public static void main(String [] args)
{
new SaoLei();
}
}