2

I have this 1st clas:

 private class proceedAL implements ActionListener
{
public void actionPerformed(ActionEvent z)
    {
        String x = (String)mouseB.getActionCommand();
        String y = (String)monitorB.getActionCommand();
        ComputerSimulator me = new connect(x,y);
    }

}

and another class:

public class ComputerSimulator extends JFrame
{
public void connect(String x, String y)
{
   String i, j;
   c2.setText(x);
   c3.setText(y);
}

This error appears: cannot find symbol - class connect

What am I missing? I'm just a starter in Programming, need some help guys

1
  • don't throw string, pass it! it is more kind =) Commented Nov 14, 2012 at 13:20

4 Answers 4

2

The correct way to instantiate an object of your class and call its method is this:

ComputerSimulator e = new ComputerSimulator();
e.connect(x, y);
Sign up to request clarification or add additional context in comments.

Comments

2

connect indeed is not class. It is a method in class ComputerSimulator.

You should create object first:

ComputerSimulator me = new ComputerSimulator()

now you can call method connect: me.connect(x, y);

Comments

0

connect is not a class, its a method on the class ComputerSimulator. You are invoking the connect method as if it were the constructor, you need to do

ComputerSimulator computerSimulator = new ComputerSimulator();
computerSimulator.connect();

Comments

0

You are having it wrong, you can only make new of a class (like ComputerSimulator).

Once you have an instance of that class, you can use its public methods (like connect) -> me.connect(x, y);

By the way, throws refers only to exception handling.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.