2011-03-29 102 views
0

下面的代碼中記錄了錯誤行。我注意到的是,如果我突出顯示Customer這個詞並按住Ctrl-T,它將顯示Customer - SwimCalc這個正確的等級。但是,如果我做同樣的承包商,它說承包商 - SwimCalc.Customer不同等級

public class SwimCalc extends JFrame implements ActionListener { 
    private JTabbedPane jtabbedPane; 
    private JPanel Customers; 
    private JPanel Contractors; 
    private List<Customer> customers = new ArrayList<Customer>(); 

    // this fails 
    private List<Contractor> contractors = new ArrayList<Contractor>(); 

    JTextArea NameTextCustomers, ExistTextCustomers, MessageTextCustomers, 
    NameTextContractors, ExistTextContractors, MessageTextContractors; 
    JTextField lengthTextPool, widthTextPool, depthTextPool, volumeTextPool; 

    public SwimCalc() { 
     setTitle("Volume Calculator"); 
     setSize (300, 200); 

     JPanel topPanel = new JPanel(); 
     topPanel.setLayout(new BorderLayout()); 
     getContentPane().add(topPanel); 

     createCustomers(); 
     createContractors(); 

     jtabbedPane = new JTabbedPane(); 
     jtabbedPane.addTab("Customer", Customers); 
     topPanel.add(jtabbedPane, BorderLayout.CENTER); 
    } 
} 
+0

那麼你的問題到底是什麼? – CoolBeans 2011-03-29 15:21:23

+0

你能告訴我們'承包商'類的定義,以及你得到的確切錯誤信息嗎? – 2011-03-29 15:22:02

+0

@Gareth:錯誤:承包商無法解析爲類型。你的定義是什麼意思?謝謝 – Mike 2011-03-29 15:26:01

回答

1

錯誤「承包人不能被解析爲一個類型」可能意味着

  • 你永遠在你的代碼
  • 寫道: class Contractor {...}任何地方
  • 的Eclipse不能編譯整個項目,因爲某些構建路徑問題(檢查構建路徑錯誤的問題視圖)
  • 你忘了導入類型Contractor
+0

當我強迫它運行一個框在底部彈出說:線程「主」的異常java.lang.Error:未解決的編譯問題:在SwimCalc.main(SwimCalc.java:558)558行是:public static void main(String [] args){ – Mike 2011-03-29 15:35:48

+0

@Mike:換句話說,如果它不能編譯,那麼你就不能運行它。我認爲這個錯誤出現在那裏,因爲這是它首先想要使用'SwimCalc'類的地方,它是沒有成功編譯的類。 – 2011-03-29 15:50:29