I need a GUI done in Java . The project involves inporting a list of judges for
ID: 3831022 • Letter: I
Question
I need a GUI done in Java. The project involves inporting a list of judges for a science fair and a list of projects by number. The names of the judges will have a list of subjects that they are qualified to judge for. The list of projects will have subject that they are part of. The code sorts the judges into groups to and assigns them to the projects they are responsible to judge. I just need the GUI I already have all the code for the processing. The GUI should look something like this:
There is FileChooser for each the subject list txt. file one for the judge list txt.file. And 3 text windows to display the original subject list and judge list and then one for the list of assigned judges with the group they are assugned to. There also should be a row of buttons to do the various tasks.
Here is an example of the project list:
403 Chemistry
412 Chemistry
400 Behavioral/Social Science
407 Chemistry
410 Chemistry
417 Life Science
415 Environmental Science
419 Life Science
411 Chemistry
420 Mathematics/Physics
421 Mathematics/Physics
408 Chemistry
409 Chemistry
406 Chemistry
401 Behavioral/Social Science
416 Environmental Science
413 Earth/Space Science
405 Chemistry
414 Environmental Science
402 Behavioral/Social Science
418 Life Science
404 Chemistry
And here is a example of the judge list:
Ben Miller: Biology, Chemistry
Joe Hansen: Chemistry, Earth Science
Jill Clemson: Behavioral/Social Science, Life Science, Environmental Science
Cathy Lively: Life Science
Francisco Aranda: Chemistry, Mathematics/Physics
Betty Baines: Environmental Science
Jim Green: Life Science
Bill Jones: Chemistry, Behavioral/Social Science, Earth/Space Science, Mathematics//Physics, Environmental Science
Susan Garcia: Life Science
Jamie Aguirre: Mathematics/Physics
Carla Phillips: Earth/Space Science
Tony Brown: Life Science
Joseph Martin: Life Science, Environmental Science
Chris Suarez: Environmental Science, Behavioral/Social Science
Sara Rodriguez: Chemistry
Karen Simi: Mathematics/Physics, Environmental Science
Maria Gonzales: Life Science, Chemistry
Leticia Jones: Chemistry
Jamie Garcia: Earth/Space Science, Mathematics/Physics, Chemistry
Here is what a section of the output will look like(this is only a small part of it):
Behavioral/Social Science_1: (400,401,402)
Chris Suarez, Bill Jones, Jill Clemson
Finally here is the main processing code I have
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import javax.swing.JOptionPane;
public class Processing {
public static LinkedList projectList = new LinkedList();
public static LinkedList judgeList = new LinkedList();
public static ArrayList alist = new ArrayList();
public Processing() {
inputStreamProjectFile("project_List.txt"); // what file has the project list (can be changed)
inputStreamJudgeFile("judge_List.txt"); // what file has the judge list (can be changed)
printLinkedLists(); // print both 'projectList' and 'judgeList' to the console
processing(); // has to be called after both inputStreams are set up to create alist
printArrayLists(); // print 'alist' to the console
outputStream("OutputGroup.txt"); // what file to save alist as (can be changed)
}
public static String judgeString(String[] a){
String judgeNames="";
String emptyPhrase="****Empty";
for(int i=0; i
if(i==0&&(!a[i].equals(emptyPhrase))){
judgeNames = judgeNames+a[i];
}else if(!a[i].equals(emptyPhrase)){
judgeNames = judgeNames+", "+a[i];
}
}
return judgeNames;
}// puts entire array 'a' into a String format of "a[0], a[1], a[2], ..."
public static String projectString(int[] a){
String projectNames="";
for(int i=0; i
if(i==0&&(a[i]!=0)){
projectNames = projectNames+a[i];
}else if(a[i]!=0){
projectNames = projectNames+", "+a[i];
}
}
return projectNames;
}// puts entire array 'a' into a String format of "a[0], a[1], a[2], ..."
public static void outputStream(String fileName){
try {
PrintWriter outputStream = new PrintWriter(new FileOutputStream(fileName));
for(OutputGroup grp: alist){
outputStream.println(
grp.category+"_"+grp.group+": ("+
projectString(grp.projects)+") "+
judgeString(grp.name)+" "
);
}
outputStream.close();
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "Error opening the file "+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
catch(Exception e){
JOptionPane.showMessageDialog(null, "Error occured "+e.getMessage(), "ERROR!", JOptionPane.ERROR_MESSAGE);
}
}// Saves current linkList to the file specified in openStream
public static int outputNewSubject(int pI, String subject){
// alist.add(new OutputGroup());
alist.add(new OutputGroup());
pI = populateOutputGroup(pI, subject, alist.size()-1, 1);
return pI;
}// creates new OutputGroup then calls method to populate
public static int subjectIsDifferent(int pI, String subject){
// subject is different
// create new entity with new subject
pI = outputNewSubject(pI, subject);
return pI;
}
public static void setJudges(String subject, int sI){
int count = 0; // keeps track of how many judges have been added, also used for index of next project to be added
int count2 = 0; // break just in case first count doesnt reach 3
while(count!=3&&count2
if(judgeList.get(count2).contains(subject)){
// add current judgeList.get(count2) to alist.get(sI).projects[count]
alist.get(sI).name[count] = judgeList.get(count2).substring(0, judgeList.get(count2).indexOf(":")); // adds just name to alist.get(sI).name[count]
count++;
}
count2++;
} // ends if backupBreak is hit or if count=6 meaning current alist.get(sI) has all 6 judges
}// sets alist.get(sI).judges
public static int setProjects(int masterProjectIndex, String subject, int sI){
int count = 0; // keeps track of how many projects have been added, also used for index of next project to be added
int pI = masterProjectIndex;
while(pI
if(projectList.get(pI).contains(subject)){
// add current projectList.get(pI) to alist.get(sI).projects[count]
alist.get(sI).projects[count] = Integer.parseInt(projectList.get(pI).substring(0, 3));
count++;
}else {
return pI;
}
pI++;
} // ends if pI is past projectLists size or if count=6 meaning current alist.get(sI) has all 6 judges
return pI;
}// sets alist.get(sI).projects
public static int populateOutputGroup(int pI, String subject, int sI, int groupNumber){
// populates new OutputGroup ' alist'
alist.get(sI).group = groupNumber; // sets groupNumber to what it should be
alist.get(sI).category = subject; // sets subject to what subject it (sense it never changed only group did)
pI = setProjects(pI, subject, sI); // calls method to set projects on alist.get(sI)
setJudges(subject, sI); // calls method to set judges on alist.get(sI)
return pI;
}// begins populating blank OutputGroup
public static int getLastGroupNumber(){
OutputGroup grp = alist.get(alist.size()-2);
int num = grp.group;
return num+1;
}// gets what the group number should be by checking the outputGroup before what groupNumber it is then adds one
public static int outputNewGroup(int pI, String subject){
// alist.add(new OutputGroup());
alist.add(new OutputGroup());
int groupNumber = getLastGroupNumber(); // groupNumber is last what the number of group it is 'Chemestry_2' group: 2
pI = populateOutputGroup(pI, subject, alist.size()-1, groupNumber);
return pI;
}// creates new OutputGroup gets what new group nummber should be then calls method to populate it
public static int subjectIsSame(int pI, String subject){
// subject is the same
// more then 6 of the same project subject exist, create new grouping
pI = outputNewGroup(pI, subject);
return pI;
}// calls method to create new OutputGroup and populate it
public static void processing(){
String subject="****Empty";
int pI=0;
while(pI!=projectList.size()){
if( projectList.get(pI).contains(subject) ){
// subject is the same
// more then 6 of the same project subject exist, create new grouping
// will create new outputgroup and then attempt to populate, returning a new pI so this program will only read each project once
pI = subjectIsSame(pI, subject);
}else {
// subject is different
// create new entity with new subject
subject = projectList.get(pI).substring(4);
// will create new outputgroup and then attempt to populate, returning a new pI so this program will only read each project once
pI = subjectIsDifferent(pI, subject);
}
}
}// creates entities of 'alist'
public static void printOutputGroup(int alistIndex){
alist.get(alistIndex).printGroup();
}
public static void printArrayLists(){
System.out.println(" ******OUTPUT GROUPS*****");
for(OutputGroup grp:alist){
grp.printGroup();
System.out.println("----------------------------------------------");
}
}// display ArrayList: 'alist' to console
public static void printJudgeList(){
System.out.println();
System.out.println(" ******JUDGES*****");
for(String x: judgeList) System.out.println(x);
System.out.println();
}
public static void printProjectList(){
System.out.println(" ******PROJECTS*****");
for(String x: projectList) System.out.println(x);
System.out.println();
}
public static void printLinkedLists(){
printProjectList();
printJudgeList();
System.out.println(" ");
}// display LinkedList: 'projectList', 'judgeList' to console
public static void sortProjects(){
String LineI, LineJ;
for(int i=0; i
for(int j=i+1; j
LineI=projectList.get(i).substring(projectList.get(i).indexOf(" ")+1);
LineJ=projectList.get(j).substring(projectList.get(j).indexOf(" ")+1);
sortProjects2(LineI, i, LineJ, j, 0);
}
}
}// sorts project list by taking project subjects and passes that to sortProjects2 to sort alphabetically
public static void sortProjects2(String str1, int index1, String str2, int index2, int indexKey){
int num1, num2;
String hold;
if((indexKey
num1 = convertCharToInt(str1.substring(indexKey, indexKey+1));
num2 = convertCharToInt(str2.substring(indexKey, indexKey+1));
if(num1==num2){
sortProjects2(str1, index1, str2, index2, indexKey+1);
}else if(num1>num2){
hold = projectList.get(index1);
projectList.set(index1, projectList.get(index2));
projectList.set(index2, hold);
}
}
} // 2 strings are compared to find which one is alphabetically first
public static int convertCharToInt(String str){
str = str.toLowerCase();
switch(str){
case "a":
return 1;
case "b":
return 2;
case "c":
return 3;
case "d":
return 4;
case "e":
return 5;
case "f":
return 6;
case "g":
return 7;
case "h":
return 8;
case "i":
return 9;
case "j":
return 10;
case "k":
return 11;
case "l":
return 12;
case "m":
return 13;
case "n":
return 14;
case "o":
return 15;
case "p":
return 16;
case "q":
return 17;
case "r":
return 18;
case "s":
return 19;
case "t":
return 20;
case "u":
return 21;
case "v":
return 22;
case "w":
return 23;
case "x":
return 24;
case "y":
return 25;
case "z":
return 26;
default:
System.exit(0);
}
return 0;
} // converts a letter to a number ('a'-'z') => (1-26)
public static void sortJudge(){
String hold;
for(int i=0; i
for(int j=i; j
if(judgeList.get(i).split(",").length>judgeList.get(j).split(",").length){
hold = judgeList.get(i);
judgeList.set(i, judgeList.get(j));
judgeList.set(j, hold);
hold = null;
}
}
}
} // Swap Sorts judgeList to be in order by which teacher can cover the least areas of science to the most
public static void inputStreamProjectFile(String projectFile){
try {
BufferedReader inputStream = new BufferedReader(new FileReader(projectFile));
String line = inputStream.readLine();
while(line!=null){
if(line!=null){
projectList.add(line);
line=inputStream.readLine();
}
}
inputStream.close();
sortProjects();
}
catch(FileNotFoundException e){
JOptionPane.showMessageDialog( null, "File was not found or could not be opened "+ e.getMessage(), "ERROR!", JOptionPane.ERROR_MESSAGE);
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "Error occured "+e.getMessage(), "ERROR!", JOptionPane.ERROR_MESSAGE);
}
}// takes in which file should be loaded as projects then runs immediatly sorting
public static void inputStreamJudgeFile(String judgeFile){
try {
BufferedReader inputStream = new BufferedReader(new FileReader(judgeFile));
String line = inputStream.readLine();
while(line!=null){
if(line!=null){
judgeList.add(line);
line=inputStream.readLine();
}
}
inputStream.close();
sortJudge();
}
catch(FileNotFoundException e){
JOptionPane.showMessageDialog( null, "File was not found or could not be opened "+ e.getMessage(), "ERROR!", JOptionPane.ERROR_MESSAGE);
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "Error occured "+e.getMessage(), "ERROR!", JOptionPane.ERROR_MESSAGE);
}
}// takes in which file should be loaded as judges then runs immediatly sorting
public static void main(String[] args){
Processing Use = new Processing();
}// end of main
}// end of class
This a separate class called OutputGroup
public class OutputGroup{
int catNum=0; // N/A
int group=1; // group: 1 group: 2 Chemistry_1, Chemistry_2
int count=0; // N/A
String category; // Chemistry, Life Science, ...
String[] name = new String[3]; // Judge names
int[] projects = new int[6]; // Project numbers
public OutputGroup(){
String emptyPhrase = "****Empty";
for(int n: projects) n = 0;
for(String x: name) x = emptyPhrase;
} // preSets up arrays on creation of new object of the OutputGroup type
public void printGroup() {
System.out.print(category+"_"+group+": (");
for(int i=0; i<6; i++){
if(i==0&&projects[0]!=0){
System.out.print(projects[i]);
}else if(projects[i]!=0){
System.out.print(", "+projects[i]);
}
}
System.out.print(") ");
for(int i=0; i<3; i++){
if(i==0&&name[i]!=null){
System.out.print(name[i]);
}else if(name[i]!=null){
System.out.print(", "+name[i]);
}
}
System.out.print(" ");
}// prints all info specified
public void setCategory(String cat) {
}// should be used to set up into that is needed on this object... but isn't
}
Thank you for your help!! I'm really no good at GUI
Permian Basin Permian Science Fair Judge Assignment import project Listing From: projects.tot Import Judges from: does Write Judging Assignments To: assignedbt Export Assignments Import Listings Limport Judges Assign Judges BehaviorallSocial Science 1: (400.401.402) Ben Miller. Biology, Chemistry Chris Suarez, Bill Jones. Jill Clemson Joe Hansen. Chemistry, Earth Science 400 BehaviorallSocial Science Jill Clemson: BehavioralNSocial Science. Life Science. Environmental Science 401 BehaviorallSocial Science Cathy Lively. Life Science Chemistry 1: (403,412,407 410.411) Maria Gonzales .Leticia Jones .Ben Miller 402 Behaviorall3ocial Science Franciso Aranda: Chemistry, MathematicsPhysics 403 Chemistry Betty Baines: Environmental Science Chemistry 2 (408.409.406 405 404) 404 Chemistry Jim Green Life Science Bill Jones: Chemistry, BehavioralrSocial Science, Earth/Space Science, Mathematics/Physics Sara Rodriguez, Leticia Jones Jamie Garcia 405 Chemistry 406 Chemistry Environmental Science EarthSpace Science 1: (413) 407 Chemistry Susan Garcia: Life Science Carla Phillips, Bill Jones, Jamie Garcia 408 Chemistry Jamie Aguirre: Mathematics/Physics 409 Chemistry Carla Phillips: Earth/Space Science Environmental Science 1 (415,416,414) 410 Chemistry Tony Brown: Life Science Karen Simi Betty Baines. Jill Clemson 411 Chemistry Joseph Martin: Life Science, Environmental Science Chris Suarez Environmental Science, BehavioraltSocial Science 412 Chemistry Life Science 1 (417.419.418) Sara Rodriguez Chemistry 413 Earth/Space Science Cathy Lively, Joseph Martin .Susan Garcia 414 Environmental Science Karen Simi Mathematics/Physics, Environmental Science 415 Environmental Science Maria Gonzales: Life Science, Chemistry MathematicsPhysics 1: (420.421) 416 Environmental Science Leticia Jones: Chemistry Franciso Aranda, Jamie Aguirre,Karen Simi Jamie Garcia: Earth/Space Sience, MathematicsjPhysics, Chemistry 417 Life Science 418 Life Science 419 Life Science 420 Mathematics Physics 421 Mathematics PhysicsExplanation / Answer
1. Fist we need to configure bootstrap to our html UI file.
2.We are adding bootsptrap because it will show reponsiveneess to entire application, so that if we open our screen in any resolution it will adjust to that resolution.
3.For adding bootstrap functionality to our application we need to add the bootstrap cdn to the html header part.
/* html file code copy this code to the html page, entire page developed by using html5 and bootstrap cdn */
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
</script>
</head>
<body>
<div class="jumbotron text-center">
<h2>Science Fair Judge Assignment</h2>
</div>
<div class="container">
<div class="row">
<div class="col-sm-4 form-group">
<label for="usr">Import Project Listings From:</label>
<input type="text" class="form-control" name="projectListings" id="projectListings">
</div>
<div class="col-sm-4 form-group">
<label for="usr">Import Judges From:</label>
<input type="text" class="form-control" name="file_name" id="file_name">
</div>
<div class="col-sm-4 form-group">
<label for="usr">Write Judging Assignment to:</label>
<input type="text" class="form-control" name="judgingAssignment" id="judgingAssignment">
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<center><button type="button" class="btn btn-success btn-lg" name="ImportListings" id="ImportListings">Import Listings</button></center>
</div>
<div class="col-sm-4 form-group">
<center><button type="button" class="btn btn-success btn-lg" name="ImportJudges" id="ImportJudges">Import Judges</button></center>
</div>
<div class="col-sm-4 form-group">
<center><button type="button" class="btn btn-success btn-lg" name="AssignJudges" id="AssignJudges">Assign Judges</button></center>
</div>
</div>
<div class="row">
<center><button type="button" class="btn btn-success btn-lg" name="ExportAssignments" id="ExportAssignments">Export Assignments</button></center>
</div>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.