问题描述
packagelistdemo;importjava.awt.BorderLayout;importjava.util.GregorianCalendar;importjavax.swing.*;publicclasssimpletabledemo{publicstaticvoidmain(String[]args){JFrameframe=newJFrame("简单表格示例程序");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);String[]columnnames={"编号","姓名","登记日期","专业","是否应届"};Object[][]data={{newInteger(1),"李明",newGregorianCalendar(2008,2,3).getTime(),"计算机专业",newBoolean(false)},{newInteger(2),"张乐",newGregorianCalendar(2008,5,7).getTime(),"自动化",newBoolean(true)},{newInteger(3),"余名",newGregorianCalendar(2008,9,21).getTime(),"计算机专业",newBoolean(true)},{newInteger(4),"郭超",newGregorianCalendar(2008,1,8).getTime(),"计算机专业",newBoolean(true)},};finalJTabletable=newJTable(data,columnnames);JScrollPanescrollpane=newJScrollPane(table);frame.getContentPane().add(scrollpane,BorderLayout.CENTER);frame.setBounds(200,200,400,120);frame.setVisible(true);}}两行错误:finalJTabletable=newJTable(data,columnnames);JTablecannotberesolvedtoatypeframe.getContentPane().add(scrollpane,BorderLayout.CENTER);Themethodadd(String,Component)inthetypeContainerisnotapplicableforthearguments(JScrollPane,String)