Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Swing, like most GUI frameworks, is an event driven environment. Basically this means, the application will wait for some kind of event to occur and then will trigger any registered listeners tha are waiting for notification for that event.</p> <p>In your case, you would simply need to register a <code>AdtionListener</code> to the button. When the user clicks it (or activates via the keyboard), the <code>actionPerformed</code> method will be called and you can execute what ever code you need.</p> <p>Check out <a href="http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html" rel="nofollow noreferrer">How to write action listeners</a> for more info.</p> <p>Swing is also a single threaded framwework. That is, all interaction with the UI must be executed from within the context of the Event Dispatching Thread.</p> <p>This also means, that any long running or blocking task MUST be executed from a separate thread so as not to block the EDT from processing incoming events and repaint request, which could make you application appear as if it has hung.</p> <p>Check out <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" rel="nofollow noreferrer">Concurrency in Swing</a> for more details</p> <p>To my mind, your game protocol is going to need some way of tracking whose round it is. This would be achieved simply via the use if a virtual token.</p> <p>The basic concept would be, unless the player has the token, they can't make a move. Once the player makes a move, that move and the token is sent to the other player.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload