不同的等级

时间:2011-03-29 15:18:18

标签: java eclipse

错误行在下面的代码中注明。我注意到的一点是,如果我突出显示单词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);  
    } 
}

1 个答案:

答案 0 :(得分:1)

错误“承包商无法解析为某种类型”可能意味着

  • 您从未在代码中的任何位置写过class Contractor {...}
  • 由于某些构建路径问题,Eclipse无法编译整个项目(请查看构建路径错误的问题视图)
  • 您忘记导入类型Contractor