Let me start by saying I'm a noob.
I want to get input from a text file through gui and perform some actions.the last time I did it I used command line argument to pass file name to get file input. The code in quote.
It works when I uncomment it and use command line argument. But since I want gui to handle that; what kind of changes do i need to make?
FYI: There are other classes which I haven't attached.
public class sample {
public static final int MAX_ROMAN_NUMERALS = 1000;
public static RomanNumeralGUI gui;
public static void main (String[] args) {
String inputLine;
int arrayLength = 0;
RomanNumeral myRomanNumeral;
RomanNumeral[] romanNumeralList = new RomanNumeral[MAX_ROMAN_NUMERALS];
// If there is no command line argument for the file name a message will be
// displayed and the program terminated.
/* if (args.length == 0) {
JOptionPane.showMessageDialog(null," There is no input file given on the command line.");
System.exit(0);
}
*/
TextFileInput in = new TextFileInput(args[0]);
inputLine = in.readLine();
while (inputLine != null) {
try {
myRomanNumeral = new RomanNumeral(inputLine);
romanNumeralList[arrayLength++] = myRomanNumeral;
} catch (IllegalArgumentException iae) {
} finally {
inputLine = in.readLine();
}
}
RomanNumeralList inOrder = new RomanNumeralList(), sorted = new RomanNumeralList();
for (RomanNumeral romanNumeral : romanNumeralList) {
if (romanNumeral != null) {
inOrder.insert(romanNumeral);
sorted.insert(romanNumeral);
}
}
Collections.sort(sorted, new RomanNumeral());
gui = new RomanNumeralGUI();
gui.setVisible(true);
}
}