0

I am making an application in java. and i am strucked at Design issue. It has a class

class UserInterface //class that 
extends JFrame // and 
implements KeyListener{  
     //so when it runs it can listen to key inputs.
     public void keyPressed(...){
       // if pressed 1 : I make an object of DoProcessingAndGetChoice class
       // and start its process() function. please see below. 
     }
.....
}

now i send this input to another class

class DoProcessingAndGetChoice{
....
public void process(){
    // got three results.
    // **I want to ask to the user which is the best result ?**
    // How to ask ?
    // UserInterace class (see above) would get all keyStrokes.
    // should i implement "keyListener"
   // would both methods (here keyPressed() and UserInterface's keyListener())
   //would be called
}
}

This DoDoProcessingAndGetChoice::process() does some processing and generates some reults and it wants to ask the user "something" about the result. (like what is the best answer.) As all keystrokes would go to UserInterface class How would i from UserInterface class keyPressed Method supply the inputs to this function.

UserInterface class is the gui frame that is only present on the desktop.

if the input goes to UserInterface class can i some how send it to the DoProcessingAndGetChoice class and in such a way that this function proceed() can proceed furthur.

Ashish Negi
  • 5,193
  • 8
  • 51
  • 95
  • See also [GUI versus Command Line](http://www.google.com/search?q=gui+versus+command+line). – trashgod Sep 09 '11 at 13:44
  • will anyone please tell why it has been downvoted so that i can rectify the errors. ? – Ashish Negi Sep 09 '11 at 13:46
  • I'm not your down-voter, but I would vote to close. IMO, there is not enough information here to propose a realistic design alternative. – trashgod Sep 09 '11 at 13:53
  • @trashgod Should i give more code and give more details of what i want? Which parts were really poor ? – Ashish Negi Sep 09 '11 at 13:56
  • An [sscce](http://sscce.org/) is always in order, but you haven't specified what problem you are trying to solve. – trashgod Sep 09 '11 at 14:01

1 Answers1

2

Without knowing more, my best guess is that you should look into actions and key bindings as show here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045