Challenges that I solved from the last checkup:
On the last checkup, I still had some unsolved issues that I needed to solve.
I was able to solve my last bug with the help of Mr. Lin, were my conversion from the ArrayList<Student> to the 2D Student Array. When I tried coding this, I tried using the designated rows and cols as my parameters in a for loop but that did not work properly as I needed a way to also print out successive Students from the ArrayList. I was able to solve the issue by using multiple count methods.
Instead of having a nested for loop, I used only one while loop and two counts: count and . The count would increase with every run of the while loop and would only increase while count was less than the number of columns designated. Colcount is another counter that increases for every loop, however, when the counter is divisible by the number of columns, it increases the row number.
I also applied this to my GUI which I will get into more later.
Implementation of GUI and debugging:
The GUI was definitely the most challenging thing to code and required a lot off troubleshooting to get work. In the end, I wasn’t able to fully create what I wanted but there will be more on that in the challenges section. In my GUI, I was able to create a user interface that showed the seating chart for a certain list of students in a specific order. The precondition was that the tables must be separated (no grouped tables like we see in our classes).
In my GUI, I was able to create multiple buttons, labels, textfields, and attach icons to these things by using java.awt.* and java.swing.*;
In order to code this, I mainly used an external library called acm which I had to import. This helps with creating the GUI and starting it, allowing for certain graphic elements to be implemented.
In order to code the actual use of the buttons, I used java.awt.event.* to insert ActionListeners and ActionCommands to program buttons to do and read certain things. Below will be my code.
Final Challenges:
Overall coding the buttons and different labels and such was not the greatest problem. But printing out the seating chart within the GUI was a task a had a lot of trouble with.
My initial idea was to create the chart within the GUI below the buttons and labels. My first idea was to create a label per student, but that quickly appeared not to work as the number of students was a variable that could not be applied to creating new labels with new positionings.
I tried to do it like such but it did not work.
My next idea was to simply use one label and concatenate a the student onto one String, and set the singular label as the String. This too did not work. My initial idea to create a blank temporary String add the names/numbers did not work as the label was never big enough and would simply print … In order to combat that, I tried setting dimensions to the label.
This did not solve the problem as every time I tried to create the chart, nothing would show up. I had to try finding a different method in order to solve this issue. Instead, was I did was every time the button to create the chart was clicked, a new JFrame was created. As long as the String did not exceed the limits of the new window, the String could be as long as it wanted. This fixed my initial problem of printing the chart out.
This, unfortunately, lead to another major issue, line breaks. I wanted to visualize the rows and columns with line breaks and spaces between the students. I quickly learned that line breaks within JLabels were not possible. I tried using multiple methods: I used “\n”, “\r”, System.lineSeparator(), System.getProperty(“line.separator”), and html tags. The html tags did work when line-breaking a simple String, but when I tried to add different instance variables to the method, it did not print out the inherent Strings but the names of the variables themselves (eg. if String test = “abc”, it would not print out “abc” but “test” itself).
While browsing the internet, I did find a glimmer of hope: a package created just for the issue.
I downloaded and manually imported the package into my project in order to use its custom methods and classes, but still did not work. I tried looking through its README textfiles and comments to no avail.
(the sas package)
This leads me to my final and yet unresolved problem. I am still unable to create the visual representations of rows and columns and instead had to explicitly state when a new row should appear.
Conclusions and Reflections
Overall the project was a challenging one, where I spent hours debugging and learning new solutions to my problems. Coding the GUI was difficult but fun because I was able to create an interactable interface which allowed for a more dynamic experience for the one using the code. I am kind of bummed out that I was not able to fully achieve what I had planned, but I am still proud of the effort and time I put into the creating what I have created so far.
Final Code: