DateGUI.java
import java.awt.*;
import javax.swing.*;
public class DateGUI extends JFrame{
DateGUI()
{
//getting the arraylist
Project1 proj = new Project1();
proj.readFile(\"C:\\\\filename\");
proj.checkDates();
ArrayList dates = proj.selectionSort();
ArrayList beforeSortArray = proj.getArrayBeforeSorting();
//GUI code
JFrame frame = new JFrame(\"Exam\");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(500,600);
// don\'t mix Swing with AWT
JPanel contain = new JPanel();
System.out.println(contain.getLayout());
frame.setContentPane(contain);
contain.setLayout(new GridLayout(1,2));
JTextArea txtarea = new JTextArea();
contain.add(txtarea);
for(int i=0; i dates = new ArrayList();
public ArrayList Finaldates = new ArrayList();
public void readFile(String filename)
{
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader(filename));
while ((sCurrentLine = br.readLine()) != null) {
if(sCurrentLine.length() == 8)
{
dates.add(sCurrentLine);
}
else
{
if(sCurrentLine.contains(\",\"))
{
String delim = \",\";
StringTokenizer tokenizer = new StringTokenizer(sCurrentLine,delim);
while(tokenizer.hasMoreElements())
{
String nextElem = tokenizer.nextElement();
if(nextElem.length() == 8)
{
dates.add(nextElem);
}
else
{
System.out.println(\"Invalid String: \"+nextElem);
}
}
}
else
{
System.out.println(\"Invalid String: \"+sCurrentLine);
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
public void checkDates()
{
for(int i=0;i getArrayBeforeSorting()
{
return dates;
}
public ArrayList selectionSort()
{
for(int i=0; i
Solution
DateGUI.java
import java.awt.*;
import javax.swing.*;
public class DateGUI extends JFrame{
DateGUI()
{
//getting the arraylist
Project1 proj = new Project1();
proj.readFile(\"C:\\\\filename\");
proj.checkDates();
ArrayList dates = proj.selectionSort();
ArrayList beforeSortArray = proj.getArrayBeforeSorting();
//GUI code
JFrame frame = new JFrame(\"Exam\");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(500,600);
// don\'t mix Swing with AWT
JPanel contain = new JPanel();
System.out.println(contain.getLayout());
frame.setContentPane(contain);
contain.setLayout(new GridLayout(1,2));
JTextArea txtarea = new JTextArea();
contain.add(txtarea);
for(int i=0; i dates = new ArrayList();
public ArrayList Finaldates = new ArrayList();
public void readFile(String filename)
{
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader(filename));
while ((sCurrentLine = br.readLine()) != null) {
if(sCurrentLine.length() == 8)
{
dates.add(sCurrentLine);
}
else
{
if(sCurrentLine.contains(\",\"))
{
String delim = \",\";
StringTokenizer tokenizer = new StringTokenizer(sCurrentLine,delim);
while(tokenizer.hasMoreElements())
{
String nextElem = tokenizer.nextElement();
if(nextElem.length() == 8)
{
dates.add(nextElem);
}
else
{
System.out.println(\"Inv.