Adam Hinx
Adam Hinx

Reputation: 215

Accessing variables from other classes

I have two classes. One class works does the calculations, whilst the other is a GUI to present them.

My problem is - I have "hard coded" a file path into my calculations class and can't seem to find a way to make it dynamic. As the code is fairly long, I uploaded it. Please tell me if you'd prefer me to paste it here.

GUI Class: http://pastebin.com/qNU7jVV0

Calculations Class: http://pastebin.com/rSGr9KL7

A solution in simple terms would be very helpful. Thanks.

Upvotes: 0

Views: 108

Answers (1)

Hans Z
Hans Z

Reputation: 4744

in Calculations Class:

public File setFile(String filepath){
    try{
        jpegFile = new File(filepath);
    }
    catch (IOException e) {
        e.PrintStackTrace();
    }
    return jpegFile;
}

now in GUI, to set the file to the given file path, just call metaData.setFile("C:\mypic.jpg");

Upvotes: 1

Related Questions