I am using a JFrame which accepts a value from the user and stores it in a variable (filePath). I want to use this value in another class. How can i hold the value from the JFrame and use it in another class?
JFrame code:
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Specify a file to save");
int userSelection = fileChooser.showSaveDialog(this);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
String filePath = fileToSave.getAbsolutePath();
}
Class code:
String filename="";
I want to get the filePath value into filename String.
Any help?