Different hierarchy
The line of error is noted in the code below. Something I notice is if I highlight the word Customer and hold down ctrl-T it brings up the hierarchy which shows Customer - SwimCalc which is right. But if I do the same with Contractor it says Contractor - SwimCalc.Customer
public class SwimCalc extends JFrame implements ActionListener {
private JTabbedPane jtabbedPane;
private JPanel Cu开发者_高级运维stomers;
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);
}
}
The error "Contractor cannot be resolved to a type" can mean
- you never wrote
class Contractor {...}
anywhere in your code - Eclipse can't compile the whole project because of some build path issues (check the Problem view for build path errors)
- You forgot to import the type
Contractor
精彩评论