package myfirst;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import java.lang.String.*;
public class MyFirst extends JFrame
{
JPanel panel=new JPanel(new BorderLayout());
JPanel panel1=new JPanel();
JPanel panel2=new JPanel(new GridLayout(7,7));
JPanel panel3=new JPanel();
JLabel y_label=new JLabel("股票");
JLabel m_label=new JLabel("公司");
JLabel lable[]=new JLabel[49];
JComboBox com1=new JComboBox();
JComboBox com2=new JComboBox();
JButton button11=new JButton("查看");
JButton button12=new JButton("删除");
JButton button31=new JButton("删除");
JButton button32=new JButton("删除");
public MyFirst()
{
super("我的毕业设计");
for(int i=0;i<49;i++){
label[i]=new JLabel("",JLabel.CENTER);//将显示的字符设置为居中
panel2.add(label[i]);//这里为什么回有错误?label[i]不可以么?
}
// for(int i=7;i<49;i++){ //初始化标签
// label[i].setText("");
// }
/*for(int i=0;i<7;i++){
label[i].setText(log[i]);
}*/
panel1.add(y_label);
panel1.add(com1);
panel1.add(m_label);
panel1.add(com2);
panel1.add(button11);
panel1.add(button12);
// panel2.add(lable[i]);
panel3.add(button31);
panel3.add(button32);
panel.add(panel1,BorderLayout.NORTH);
panel.add(panel2,BorderLayout.CENTER);
panel.add(panel3,BorderLayout.WEST);
panel.setBackground(Color.BLUE);
panel1.setBackground(Color.white);
panel2.setBackground(Color.PINK);
panel3.setBackground(Color.red);
setContentPane(panel);
//Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
//ImageIcon ii=new ImageIcon("/");
//setTitle(STitle);
//setIconImage(ii.getImage());
setSize(1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
int w=getSize().width;
int h=getSize().height;
//int x=(dim.getSize().width-w)/2;
//int y=(dim.getSize().height-h)/2;
int x=(int)(Toolkit.getDefaultToolkit().getScreenSize().width-w)/2;
int y=(int)(Toolkit.getDefaultToolkit().getScreenSize().height-h)/2;
// setLocation(w,h);
setLocation(x,y);
setVisible(true);
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(false);
MyFirst my=new MyFirst();
my.getContentPane();
}
}
请问叔祖那为什么不能那样写呢?