How do i pass file name ("chosenFileName") from sample2 class to sample1 class? An example would be nice.
here's some code from sample 2 class -
private void openFile( ) {
JFileChooser chooser;
int status;
chooser = new JFileChooser( );
status = chooser.showOpenDialog(null);
if (status == JFileChooser.APPROVE_OPTION)
readSource(chooser.getSelectedFile());
else
JOptionPane.showMessageDialog(null, "Open File dialog canceled");
}
private void readSource(File chosenFile) {
String chosenFileName = chosenFile.getName();
TextFileInput inFile = new TextFileInput(chosenFileName);
String inputLine;
inputLine = inFile.readLine();
int arrayLength = 0;
while (inputLine != null) {
try {
RomanNumeral romanNum = new RomanNumeral(inputLine);
romanText[arrayLength++] = romanNum;
} catch (IllegalArgumentException iae) {
} finally {
inputLine = inFile.readLine();
}
}
inOrder = new RomanNumeralList();
sorted = new RomanNumeralList();
for(RomanNumeral romanNum : romanText) {
if(romanNum != null) {
inOrder.insert(romanNum);
sorted.insert(romanNum);
}
}
Collections.sort(sorted, new RomanNumeral());
}
}