Procedural Event Driven Model for – stuck? [command line argument] [graphical objects]

admin / May 19th, 2011/ Posted in Software / No Comments »

Re:You don't need to do threads explicitly. Have the menu selections fire events, and register event listeners in your GUI to respond to those events. I believe that's all you need to accomplish what you want to do.

Check out Sun's own Event tutorial (http://java.sun.com/docs/books/tutorial/uiswing/events/index.html) as a starting point.


Re:could you give me an example of how i would do that?

lets say i have the following

public class UserInterface extends JFrame implements Runnable, ActionListener

private String userchoice = "";

public String chooseFromMenu()
{

return userChoice
}

public void ActionPerformed(ActionEvent e)
{
}

public void run()
{
}

what to change??
thanks in advance


Re:Originally posted by: guy
Threads is the solution???

someone i know suggested that i turn the methods into threads, and while the input is not some value that is useful to me, set the thread to wait(), and once I have the actionperformed method execute – change the value i need, and then just notifyAll(). Would this work – and secondly – how the heck do you turn a method into a thread?

Yea man, threads. You should have like… a GUI thread and a worker thread.


Re:Threads is the solution???

someone i know suggested that i turn the methods into threads, and while the input is not some value that is useful to me, set the thread to wait(), and once I have the actionperformed method execute – change the value i need, and then just notifyAll(). Would this work – and secondly – how the heck do you turn a method into a thread?


Re:Is there any way to force a GUI to stay in the method for initial menu until the user hits a mouseclick, and then move on.

This is the block of code that calls the initialMenu() method – since initial menu simply returns a string, even if that string has not been initialized with the proper value.

while (!done)
{
try
{
String output = "\n" + player.getName() + "'s turn.";
Game.display.show(output);
String choice = this.display.initialMenu();
Command com = dispatch.getComm(choice);
com.execute(board);

if (com instanceof RollCmd)
player = board.nextPlayer();

} // try block

I am following a command pattern if that clears things up.


Re:What's the problem?

Related posts


Tags: ,

Leave a Reply

Name required

Mail (will not be published) required

Website