So I've managed to make the program work but my professor asks for it to be done in GUI format. The issue is, I've tried to make whatever I have work with a GUI supplement but I'm fairly new with how this works. I've looked through many sites and questions on here but I'm not too familiar with how this works. I'm worried I'll mess with my code so I just want to have an idea of how I can implement the GUI into this.
I've tried to make it so that some of the text do appear in a Pane but I don't know how to incorporate with GUI when inputting -1 as an indication that the inputs are in as well as using this concept on string course = keyboard.next();
In short, I'm just at a loss with this.
Some important things to look at [The Code without the mess I made with GUI]
import javax.swing.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.io.File;
public static void main (String [] args)
{
HashMap <Integer, ArrayList <String>> students = new HashMap <>();
System.out.println ("This program correlates ID with student courses\n");
int currentID;
boolean editing;
while (true) {
System.out.println ("Please enter Student ID: \n(Then enter a -1 when inputs are done)");
Scanner keyboard = new Scanner (System.in);
int ID = keyboard.nextInt();
if(ID == -1) {
break;
}
students.put (currentID = ID, new ArrayList<>());
editing = true;
System.out.println("Enter courses: \n(Once you're done, type \'next\')");
while (editing) {
String course = keyboard.next();
if(course.equalsIgnoreCase("next")) {
editing = false;
} else {
students.get(currentID).add(course);
}
}
}
System.out.println ("Final List: ");
students.forEach((key, value) -> {
System.out.println("Student " + key + ". Courses: " + Arrays.toString(value.toArray()));
});
}
The Program information that's expected: enter image description here