开发者

Two Separate Errors

The first error is:

"Contractor cannot be resolved to a type"

private List&l开发者_运维技巧t;Contractor> contractors = new ArrayList<Contractor>();

Second error is:

"The method createContractors() is undefined for the type FVolume"

createContractors();

Here is a larger section of code that has both lines.

import java.awt.*;
import javax.swing.*;

import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.util.List;

public class FVolume extends JFrame implements ActionListener{
    private JTabbedPane jtabbedPane;

    private JPanel Customers;
    private JPanel Contractors;

    private List<Customer> customers = new ArrayList<Customer>();
    private List<Contractor> contractors = new ArrayList<Contractor>();

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

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

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

        createCustomers();
        createContractors();


        jtabbedPane.addTab("Customers", Customers);
        jtabbedPane.addTab("Contractors", Contractors);

        topPanel.add(jtabbedPane, BorderLayout.CENTER);

    }

    public void setField(String str) 
    { 
        NameTextCustomers.setText(str); 
        NameTextCustomers.validate(); 
        NameTextContractors.setText(str); 
        NameTextContractors.validate(); 
    }

I'm not sure if the problem is in the code I attached, or in a different place.


First, decide if Contractor is going to be a type (Class) or a property name.

Then, embrace the standard by which variables start with lower case letters.

Finally, if Contractor is a Class, then look in the same package (directory) as this file, if you don't have a Contractor.java file (or a Contractor.class) file, see if Contractor is in a different package. If so, then add an import xxx.xxx.xxx.Contractor; directive to this file.

Unfortunately, it's not possible to go beyond this point meaningfully, as there's already been too many _if_s in the above steps to know which path you may take.


for the first error import is missing for the class Contractors. So add this import statement along with other imports.

for the second error, the method which you are calling is not defined anywhere in the FVolume class, So define it. Or if it is present in some other class then create an instance of that class and invoke on that object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜