package com.imooc;//(報(bào)錯(cuò)一)import java.awt.FlowLayout;import java.awt.GridLayout;import javax.swing.JCheckBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.UIManager;public class LottoMadness extends JFrame {private static final long serialVersionUID = 1L;JPanel[] row=new JPanel[6];//創(chuàng)建組件JCheckBox[] check=new JCheckBox[2];JLabel quick=new JLabel("Quick");JLabel personal=new JLabel("Personal");public LottoMadness(){//創(chuàng)建外框super("Lotto Madness");setSize(600,400);setLookAndFeel();setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setVisible(true);//分配空間for(int i=0;i<6;i++){row[i]=new JPanel();}for(int i=0;i<2;i++){check[i]=new JCheckBox();}//添加組件,管理器GridLayout layout=new GridLayout(6,1,1,1);setLayout(layout);for(int i=0;i<6;i++){add(row[i]);//(報(bào)錯(cuò)二)}// FlowLayout layout0=new FlowLayout(FlowLayout.CENTER);}public void setLookAndFeel(){try{UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");}catch(Exception e){System.out.println("setLookAndFeel出錯(cuò)"+e);}}/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubnew LottoMadness();}}
3 回答

炎炎設(shè)計(jì)
TA貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個(gè)贊
我的myeclipse6.5也出現(xiàn)了這個(gè)問題,我是這樣修改的,先裝jdk-7u79-windows-x64,然后右擊項(xiàng)目->Build Path->confidure Build Path->Java Build Path->Libraries->JRE System Library[Myexlipse 6.5]->Edit->Alternate JRE->Installed JRES->Add->Browse選擇你新安裝的jre地址就可以了,希望可以幫到你

富國滬深
TA貢獻(xiàn)1790條經(jīng)驗(yàn) 獲得超9個(gè)贊
add方法的參數(shù)類型是Componet,而row[i]的類型是JPanel,所以會(huì)報(bào)錯(cuò)
添加回答
舉報(bào)
0/150
提交
取消