org.jogre.awt
Class JogreClientFrame
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Window
|
+--java.awt.Frame
|
+--javax.swing.JFrame
|
+--org.jogre.awt.JogreClientFrame
- All Implemented Interfaces:
- Accessible, IClient, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants
- public abstract class JogreClientFrame
- extends JFrame
- implements IClient
This abstract class declares the main game frame where a user can see
users of the left, tables on the top right and a broadcasting style message
chat box on the bottom right. To create a new client frame for a game, such
as Chess for example, a class called e.g. ChessClientFrame extends this class
and implements the following two abstract methods:
- public abstract ClientConnectionThread getClientConnectionThread (Socket connection, String username, IClient clientInterface);
- public abstract JogreTableFrame getJogreTableFrame (ClientConnectionThread conn, Table table);
For the chess example this would look something like the following:
public ClientConnectionThread getClientConnectionThread (
Socket connection, String username, IClient clientInterface
) {
// return a "Chess" client connection thread
return new ChessClientConnectionThread (
connection, username, (IChessClient)clientInterface
);
}
public JogreTableFrame getJogreTableFrame (
ClientConnectionThread conn, Table table
) {
// return a "Chess" table frame when join/creating a new table.
return new ChessTableFrame (conn, table);
}
- Version:
- Alpha 0.1
- Author:
- Bob Marks
- See Also:
- Serialized Form
Fields inherited from class java.awt.Frame |
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Methods inherited from class javax.swing.JFrame |
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
Methods inherited from class java.awt.Frame |
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle |
Methods inherited from class java.awt.Window |
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus |
JogreClientFrame
public JogreClientFrame()
- Constructor for a client frame.
getClientConnectionThread
public abstract ClientConnectionThread getClientConnectionThread(Socket connection,
String username,
IClient clientInterface)
- This must be overwritten to get a handle on the correct connection.
- Parameters:
connection
- username
- clientInterface
- - Returns:
-
getJogreTableFrame
public abstract JogreTableFrame getJogreTableFrame(ClientConnectionThread conn,
int tableNum)
- This must be overwritten to get a handle on the correct table frame.
- Parameters:
conn
- tableNum
- - Returns:
-
receiveConnection
public void receiveConnection(CommConnect commConnect)
- Recieve connection from the server.
- Specified by:
receiveConnection
in interface IClient
- See Also:
IClient.receiveConnection(org.jogre.comm.CommConnect)
receiveMessage
public void receiveMessage(String usernameFrom,
String messageText)
- Method which receives a message from the server (or user)
- Specified by:
receiveMessage
in interface IClient
- See Also:
IClient.receiveMessage(java.lang.String, java.lang.String)
userListUpdated
public void userListUpdated()
- Method to update the user list.
- Specified by:
userListUpdated
in interface IClient
tableListUpdated
public void tableListUpdated()
- Update the table list.
- Specified by:
tableListUpdated
in interface IClient
tableUpdated
public void tableUpdated(int tableNum)
- Update a single table.
- Specified by:
tableUpdated
in interface IClient
- See Also:
IClient.tableUpdated(int)
refreshTableFrame
protected void refreshTableFrame(Table table)
- Refresh the table.
- Parameters:
table
-
getTableFrame
protected JogreTableFrame getTableFrame(Table table)
- Return the correct JogreTableFrame. This method also adds a listener
so that when it closes down it does so cleanly.
- Parameters:
table
- - Returns:
-
getTableFrame
protected JogreTableFrame getTableFrame(int tableNum)
- Overloaded version when you are sure that the table exists (other wise
returns null).
- Parameters:
tableNum
- - Returns:
-
receiveInvite
public void receiveInvite(CommInvite invite)
- Recieve invite communications object.
- Specified by:
receiveInvite
in interface IClient
- See Also:
IClient.receiveInvite(org.jogre.comm.CommInvite)
receivePrivateMessage
public void receivePrivateMessage(String usernameFrom,
String messageText)
- Recieve a private message.
- Specified by:
receivePrivateMessage
in interface IClient
- See Also:
IClient.receivePrivateMessage(java.lang.String, java.lang.String)
receiveTableMessage
public void receiveTableMessage(String usernameFrom,
int tableNum,
String messageText)
- Receive a message for a speicificied table.
- Specified by:
receiveTableMessage
in interface IClient
- See Also:
IClient.receiveTableMessage(java.lang.String, int, java.lang.String)
startGame
public void startGame(int tableNum)
- Start the game.
- Specified by:
startGame
in interface IClient
- See Also:
IClient.startGame(int)
receiveOfferDraw
public void receiveOfferDraw(CommOfferDraw commOfferDraw)
- Receive an offer to draw the game from a user.
- Specified by:
receiveOfferDraw
in interface IClient
- See Also:
IClient.receiveOfferDraw(org.jogre.comm.CommOfferDraw)
gameOver
public void gameOver(CommGameOver commGameOver)
- Recieve game over.
- Specified by:
gameOver
in interface IClient
- See Also:
IClient.gameOver(org.jogre.comm.CommGameOver)