CS212 Project Part 1
Frequently Asked Questions
Q. How do I display a JList?
A. To put a JList into your GUI, you need to first place it into a JScrollPane, and then put the JScrollPane into your JPanel.
Q. What do I put into my JLists?
A. You can put any type of Object into a JList. To display each Object, JList calls the Object's toString() method. Thus, you could place Election objects into a JList, as long as you override the toString() method in the Election class. Just be careful... the client and server display different things when displaying elections and candidates.
Q. Is there a way to update my GUI?
A. To update the display of your JList, use the repaint() method. You can also use the repaint() method on other components if you notice they aren't displaying updated information.
Q. Do I have to use hashtables?
A. In class I mentioned using hashtables to store elections and other objects... you don't have to use them. Indeed, it may be easier for you if you don't.
Q. Do I need to save vote counts when the server is shut down?
A. No. Assume the server won't shut off during elections (a poor assumption, but no big deal for us).
Q. What kind of listener should I use to detect changes in list selections?
A. Check out ListSelectionListener