GUI Layout
Thursday, June 18, 2009 18:15I was casually working on my SOS program this week, until last night, when I shifted into over-drive and was determined to get a decent graphical user interface (GUI) to display the different views going. I actually got so caught up in it that I was up until 1AM, but I don’t mind.
I know, creating a GUI is kind of useless without the underlying logic working yet, however, to mix things up I switch between working on the front-end (GUI) and the back-end (logic) of my program, depending on what I feel like that day. I have most, if not all, the functions in place so that I can make calls to them when necessary, even though it is more of a skeleton at this point since quite a few methods are not implemented yet.
GUIs can be tricky business at times, in order to get them to layout the way you have visualized in your mind and more importantly updating correctly to stay in sync with the back-end. If the user is not presented with the latest information then they cannot make an informed decision/play. In this case, it could be not displaying the previous players move prior to them moving, not showing the last point scored until another point was scored, to incorrectly displaying whose turn it is. I haven’t added the last one as a function of my program, as of yet, but I intend to at one point.
One of my little struggles was the PlayerView, as I wasn’t using the GROUP component correctly, causing run-time errors. The other was getting the GridBagLayout and GridBagConstraints to function correctly. I was not sure how to use these two classes, so I did some reading and testing with a simplified case, and now I believe I have a much better understanding of how it handles and lays out its components. This allowed me to get most of the components in the desired place.
I have included a snapshot of what my GUI looks like at this stage. It is by no means the final version as I do not even have some buttons added at the moment.
