java - 不同的层次结构

标签 java eclipse

下面的代码中指出了错误行。我注意到,如果我突出显示“客户”一词并按住 ctrl-T,它会调出显示“客户 - 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);  
    } 
}

最佳答案

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

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

关于java - 不同的层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5474859/

相关文章:

java - Eclipse:抑制, "cannot be resolved to a type"

android - 为什么 ADT Bundle 20140702 中缺少 fragment_main.xml?

java - 如何从表中恢复数据并将其存储到列表中?

java - DDD : How to hide specific aggregate root constructors from integration layers in Kotlin

java - Weblogic 管理控制台太慢了

java - 为什么在启动运行配置时 Eclipse 会以 "Verifying launch attributes..."状态挂起 57%?

java - 如何防止 Eclipse 为每次构建清理 bin 文件夹?

Eclipse 的 PHP 困惑检测器

eclipse - "Unable to find XXX.gwt.xml on your classpath"GWT 错误

Java 套接字和丢弃的连接