I have created one GUI.java file

inside it i have written a code of GUI,which includes filechooser and button.

I also have created logic.java file, inside it i have write my logic for performing some operation.

On the click event of button, i want to pass a path chosen by filechooser to the logic.java file.

I also have created constructor of logic(String s) and pass that path inside it.

I ahve write

public void actionPerfomed(ActionEvent ae)
    String ss = tf1.getText();//for taking input from filechooser
    logic cc = new logic(ss);

but this doesn't work any more.means logic.java file can't be called.

please help me out, how can i call logic.java file with also passing argument of String got through filechooser.


no problem with that code at all.
do you get an error message? have you checked the value of the path you are trying to pass?

there is no error message,but whatever written in logic.java is not executed.

Also i don't get that passed string in logic's constructor. so what to do?

well, I assume tf1 is a textfield in which your path is stored after retrieving it by the JFileChooser?
what do you mean: I don't get that passed String in logic's constructor? either it gets there, (being null if that 's tf1.getText() s value, but 'll get there) or there will be an error message.

did you try by adding some print statements to check whether all variables have the values you think they do?

yes tf1 is a textfield and i also get whole path retrieved by filechooser.
Also i have print the value of that tf1 and also path is printed.

but how can i pass that file path to another java file(logic.java)?
i also tried to print that ss value in println statement, but it gives nothing.

there will no error message.

Both java files are in same directory. still one file can't pass one string to another java file.

what you are saying makes little sense, I'm afraid. by passing it as a parameter to the constructor, you ARE passing that String to that other class. might be a problem in your logic class, where you don't actually set the value?