Monday, October 29, 2007

Java: DII Character Simulator

I've started working on the look & feel portion of the Diablo II character simulator program I mentioned earlier. I'm working on this one piece at a time, as I wanted to get the visual layout accomplished first before putting any functionality into the application.



The layout for the skill calculator portion ended up requiring 2273 lines of code. The main reason for this is that for each character type I needed to create and populate 3 JPanels, 30 JComboBoxes and at least 50 JLabels and then combine them together in a GroupLayout manager to display properly. I decided on the GroupLayout manager due to its versatility, I was able to display the JLabels and JComboBoxes in the format I desired. All of the other layout managers were more restrictive as to where these components could be placed and I was looking for a very specific appearance.
GroupLayout is new as of Java Platform 6 so I needed to update my software a bit. A new JRE was downloaded along with updating my browser shortcut to the API reference, as I was using version 5 up until now. I severely doubt I would have been able to create the application display as I did with any other layout manager, at least not as easily as GroupLayout made the process. There was a bit of a learning curve, as up to this point FlowLayouts and GridLayouts were my managers of choice, but I'm happy with the results.

Each of the character displays is generated in its own method and these methods are the reason for the length of the class file. I am considering separating these methods out into their own class files to cleanup the code to make it more compartmentalized, however I will deal with that once the look & feel portion of the application is accomplished.

Next up, the equipment tab appearance.

No comments: