|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttipgame.util.GameSelector
public class GameSelector
this class takes care of connecting networked games.
| Nested Class Summary | |
|---|---|
private class |
GameSelector.GameSelectionListener
updates the session spinner when a game is selected |
private class |
GameSelector.JoinGameListener
joins or starts a game |
private class |
GameSelector.QuitGameListener
breaks connection with the server and exits |
private class |
GameSelector.RefreshGameListListener
reloads information from the server |
| Field Summary | |
|---|---|
private java.util.TreeMap<java.lang.String,java.lang.Class> |
classes
map of game name to class that extends GameLoop |
private javax.swing.JFrame |
frame
the frame for the GUI |
private javax.swing.JComboBox |
gameSpinner
the selection of games on this computer |
private java.io.ObjectInputStream |
in
connection from the server |
private javax.swing.JButton |
joinButton
the button for starting the game |
private java.io.ObjectOutputStream |
out
connection to the server |
private javax.swing.JSpinner |
playerSpinner
the option for number of players |
private javax.swing.JButton |
quitButton
the button for exit |
private javax.swing.JButton |
refreshButton
the button for refreshing information from the server |
private Server |
server
server connected to |
private javax.swing.JTextField |
serverField
where the user puts the server to connect to |
private java.util.HashMap<java.lang.String,java.util.TreeSet<java.lang.String>> |
sessions
map of games to sessions |
private javax.swing.JComboBox |
sessionSpinner
the selection of sessions for a given game |
| Constructor Summary | |
|---|---|
GameSelector()
initializes the GUI, connects to the server on the local machine and displays the games/sessions running |
|
| Method Summary | |
|---|---|
private void |
connect()
connects to the server |
static java.lang.String |
getHostname()
gets the name of the localhost on the network |
private void |
join()
sends the join command to the server |
private void |
loadGames()
gets the list of game and sessions from the server |
static void |
main(java.lang.String[] argv)
makes the GUI and sets up information from the localhost server |
private void |
makeComponents()
initializes the components and sets up the listeners |
private void |
makeLayout()
lays out the components on a grid in the frame |
private void |
refresh()
reads information from the server and updates the listed games and sessions |
private void |
refreshSpinners()
refreshes the sessions to match the game |
private void |
setVisible(boolean vis)
makes the GUI visible or invisible |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private javax.swing.JFrame frame
private javax.swing.JTextField serverField
private javax.swing.JComboBox gameSpinner
private javax.swing.JComboBox sessionSpinner
private javax.swing.JSpinner playerSpinner
private javax.swing.JButton joinButton
private javax.swing.JButton quitButton
private javax.swing.JButton refreshButton
private java.util.HashMap<java.lang.String,java.util.TreeSet<java.lang.String>> sessions
private java.util.TreeMap<java.lang.String,java.lang.Class> classes
private java.io.ObjectOutputStream out
private java.io.ObjectInputStream in
private Server server
| Constructor Detail |
|---|
public GameSelector()
| Method Detail |
|---|
private void setVisible(boolean vis)
vis - true means make visible, false means hideprivate void makeLayout()
private void refresh()
private void refreshSpinners()
private void connect()
public static java.lang.String getHostname()
private void makeComponents()
private void join()
private void loadGames()
public static void main(java.lang.String[] argv)
throws java.lang.Exception
argv - not used
java.lang.Exception - if communications to the server break
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||