|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object examples.tictactoe.TicTacToeAgent
This class is mobile code, which will migrate through the peer-network and enables user to exchange textmassages with each other.
Nested Class Summary | |
class |
TicTacToeAgent.JIconButton
|
Constructor Summary | |
TicTacToeAgent()
Creates an object of the class TicTacToeAgent |
Method Summary | |
void |
actionPerformed(ActionEvent aEvent)
Defines the specific action sequence of all buttons of this class |
private JPanel |
createBoardPane()
|
private JPanel |
createTalkPane()
Method enables the user to create and read textmessages with th choosen chat-partner. |
private void |
drawBoardPart(Image img,
int x,
int y,
int xWidth,
int yWidth,
Graphics g,
Component comp)
|
private void |
drawBoardPart(Image img,
Rectangle rect,
Graphics g,
Component comp)
|
private void |
drawBoardWinner(int winner,
Graphics g,
Component comp)
|
private void |
drawHighScore(Graphics g,
Component comp)
Print the Highscore |
private ArrayList |
findTargets()
Get a list of all peers found in the VICINITY-network |
private boolean |
gameEnd()
Returns true if a game is at end |
private void |
gameGUI()
Method enables the user to play with the choosen game-partner. |
private ImageIcon |
getImageFromResource(Resource resource,
String name)
Loads an Icon from Agent's Resource |
private void |
initGUI()
Method enables the user to choose a game-partner in the VICINITY-network |
private boolean |
isHome()
Get a list of all peers found in the VICINITY-network |
private LinkedList |
loadHighScore()
Loads the Highscore |
static void |
main(String[] argv)
This method is used for the initial launch of the agent from the jshell. |
void |
mouseClicked(MouseEvent e)
|
void |
mouseDragged(MouseEvent e)
|
void |
mouseEntered(MouseEvent e)
|
void |
mouseExited(MouseEvent e)
|
void |
mouseMoved(MouseEvent e)
|
void |
mousePressed(MouseEvent e)
|
void |
mouseReleased(MouseEvent e)
|
private void |
offerRevenge()
|
private boolean |
printHighScore()
Returns true if HighScore can be printed |
private LinkedList |
quicksort(LinkedList qsliste)
Sortieralgorithmus |
void |
resume(ErrorCode err)
After an agent was suspended on a peer, he will migrate to >null< and terminate. |
void |
run()
This method will be executed after an agent has reached a peer. |
private void |
saveHighScore()
Save the Highscore |
private LinkedList |
updatedHighScore()
Save the Highscore |
void |
windowActivated(WindowEvent wEvent)
Is not spezified in this program |
void |
windowClosed(WindowEvent wEvent)
When window closed the agent will leave his locked state |
void |
windowClosing(WindowEvent wEvent)
Dispose all windows and terminate agent |
void |
windowDeactivated(WindowEvent wEvent)
Is not spezified in this program |
void |
windowDeiconified(WindowEvent wEvent)
Is not spezified in this program |
void |
windowIconified(WindowEvent wEvent)
Is not spezified in this program |
void |
windowOpened(WindowEvent wEvent)
Is not spezified in this program |
private static void |
writeImageToResource(Resource resource,
String name)
Writes an Image to Agent's Resource |
private static void |
writeToResource(Resource resource,
InputStream in,
String name)
writes a stream to resource with the identifying name |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final boolean DEBUG
static final String IMAGE_PATH
static final String HIGHSCORE_PATH
static final String STATUS_STYLE
static final String HOME_STYLE
static final String AWAY_STYLE
static final String DEFAULT_STYLE
private transient JFrame initFrame_
private transient JFrame gameFrame_
private transient JComboBox serverChoiceBox_
private transient MobilityContext mob_
private transient JButton destButton_
private transient ImageIcon icon_
private transient ImageIcon opalIcon_
private transient ImageIcon iconO_
private transient ImageIcon iconX_
private transient ImageIcon opalIconO_
private transient ImageIcon opalIconX_
private transient ImageIcon hideIcon_
private transient ImageIcon hideIcon1_
private transient ImageIcon hideIcon2_
private transient ImageIcon hideIcon3_
private transient ImageIcon showIcon_
private transient ImageIcon showIcon1_
private transient ImageIcon showIcon2_
private transient ImageIcon showIcon3_
private transient ImageIcon exitIcon_
private transient ImageIcon exitIcon1_
private transient JTextPane convHist_
private transient JTextField convInput_
private transient JPanel talkPane_
private transient boolean printHighScore_
private String homeLocation_
private String awayLocation_
private static URL[] hosts_
private static boolean test_
private HighScoreEntry homeEntry_
private HighScoreEntry awayEntry_
private LinkedList convList_
private ArrayList urls_
private int convListIndex_
private String home_
private String source_
private String dest_
private Object lock_
private AgentCard myCard_
private TicTacToeBoard tBoard_
Constructor Detail |
public TicTacToeAgent()
Method Detail |
public void resume(ErrorCode err)
resume
in interface Resumable
err
- ErrorCode
Error, which is appeared during the program executionpublic void run()
run
in interface Runnable
InterruptedException
- Interrupts the wait-state of the agentprivate boolean gameEnd()
private boolean printHighScore()
private void initGUI()
private JPanel createTalkPane()
Exception
- If a problem with the inet-addresses happensprivate void gameGUI()
Exception
- If a problem with the inet-addresses happensprivate void drawBoardPart(Image img, int x, int y, int xWidth, int yWidth, Graphics g, Component comp)
private void drawBoardPart(Image img, Rectangle rect, Graphics g, Component comp)
private void offerRevenge()
private void drawBoardWinner(int winner, Graphics g, Component comp)
private JPanel createBoardPane()
public void actionPerformed(ActionEvent aEvent)
actionPerformed
in interface ActionListener
aEvent
- ActionEvent
An event from one of the GUI components.
Exception
- If there are migration problemspublic void windowClosed(WindowEvent wEvent)
windowClosed
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.public void windowClosing(WindowEvent wEvent)
windowClosing
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.public void windowActivated(WindowEvent wEvent)
windowActivated
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.public void windowDeactivated(WindowEvent wEvent)
windowDeactivated
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.public void windowDeiconified(WindowEvent wEvent)
windowDeiconified
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.public void windowIconified(WindowEvent wEvent)
windowIconified
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.public void windowOpened(WindowEvent wEvent)
windowOpened
in interface WindowListener
wEvent
- WindowEvent
An event from one of the windows.private boolean isHome()
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
private ArrayList findTargets()
private static void writeToResource(Resource resource, InputStream in, String name)
in
- The InputStream to read fromname
- The name identifying the data of which
an output stream is requestedprivate static void writeImageToResource(Resource resource, String name)
private LinkedList quicksort(LinkedList qsliste)
private void drawHighScore(Graphics g, Component comp)
private LinkedList updatedHighScore()
private void saveHighScore()
private LinkedList loadHighScore()
private ImageIcon getImageFromResource(Resource resource, String name)
public static void main(String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |