日期:2014-05-20  浏览次数:20865 次

万年历部分代码,为什么会有异常,请指导,谢谢
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.JTabbedPane;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import java.util.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

class CalculatorFrame extends JFrame {
  JPanel contentPane;
  Border border1 = BorderFactory.createLineBorder(SystemColor.controlText, 2);
  Border border2 = BorderFactory.createLineBorder(SystemColor.controlText, 2);
  JTabbedPane jTabbedPane1 = new JTabbedPane();
  JPanel jPanel1 = new JPanel();
  JPanel jPanel2 = new JPanel();
  Border border3 = BorderFactory.createLineBorder(SystemColor.controlText, 2);
  Border border4 = BorderFactory.createEtchedBorder(EtchedBorder.RAISED,
  new Color(248, 248, 248), new Color(121, 121, 121));
  JComboBox jComboBox1 = new JComboBox();
  JPanel jPanel4 = new JPanel();
  GridLayout gridLayout1 = new GridLayout(7,7);
  java.util.List linkedList = new LinkedList();
  JSpinner jSpinner1;
  JLabel[] jLabel = new JLabel[49];
  GregorianCalendar cal1 = new GregorianCalendar();
  int month = cal1.get(Calendar.MONTH);
  int year = 2007;
  JButton jButton1 = new JButton();


  public CalculatorFrame() {
  try {
  setDefaultCloseOperation(EXIT_ON_CLOSE);
  jbInit();
  } catch (Exception exception) {
  exception.printStackTrace();
  }
  }

  /**
  * Component initialization.
  *
  * @throws java.lang.Exception
  */
  private void jbInit() throws Exception {
  contentPane = (JPanel) getContentPane();
  contentPane.setLayout(null);
  setSize(new Dimension(543, 444));
  setTitle("Calculator");
  jTabbedPane1.setBounds(new Rectangle(19, 37, 494, 336));
  jPanel1.setLayout(null);
  jPanel2.setBorder(border4);
  jPanel2.setBounds(new Rectangle(15, 28, 269, 241));
  jPanel2.setLayout(null);
  jComboBox1.setBounds(new Rectangle(13, 21, 82, 30));
  jComboBox1.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
  jComboBox1_actionPerformed(e);
  }
  });
  for(int i=1980;i<3000;i++){
  linkedList.add(new Integer(i));
  }
  jSpinner1 = new JSpinner(new SpinnerListModel(linkedList));
  jSpinner1.setToolTipText("");
  jSpinner1.setBounds(new Rectangle(163, 21, 82, 30));
  jPanel4.setBackground(Color.white);
  jPanel4.setBounds(new Rectangle(13, 65, 232, 157));
  jPanel4.setLayout(gridLayout1);
  jButton1.setBounds(new Rectangle(350, 102, 75, 61));
  jButton1.setText("jButton1");
  contentPane.add(jTabbedPane1);
  jTabbedPane1.add(jPanel1, "时间和日期");
  for(int i = 1;i<=12;i++){
  jComboBox1.addItem(i+"月");
  }
  jLabel[0] = new JLabel("日");
  jPanel4.add(jLabel[0]);
  for(int i =1;i<7;i++){
  jLabel[i] = new JLabel(""+i);
  jPanel4.add(jLabel[i]);
  }