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