Results 1 to 3 of 3
  1. #1
    simo_mon is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default [SOLVED] event handling :backend and front end seperation

    hi there i have a conceptual question...

    i have a gui, which reads keystroke events attached to a textfield

    ie
    Java Code:
      class Myclass extends JFrame implements ActionListener,KeyListener {
    
       constructor....
    
       public void keyPressed(KeyEvent e) 
       {
    	System.out.println(" a key has been pressed ");
    	System.out.println(" a key code "+e.getKeyCode());
    	System.out.println(" a key char  "+e.getKeyChar());
       }
    
    }
    no i am trying to keep a seperation between the gui and the backend... so the backend will store and adjust the data ...

    ie
    Java Code:
        class back{
        
        private int total =;
    
        constructor...
    
        get/set total();
    my question is can i link the adjustment of the total in the back class, everytime a keystroke is fired in the gui...?

    is it that i add a listener to the back class???

    the whole idea being here to keep a logical and functional seperation between the gui and the data manipulation part....

    thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Listeners could work great here. Perhaps you need a 3-part program: View and Model as you have, and also a Control to handle the actions.

  3. #3
    simo_mon is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default

    wow.... thanks Fubarable ..... that was some code explosion !!!!!!
    the listeners were the missing link !!!!!!! Went off and added the keylisteners to the backend, passed a ref to the front and viola !!!!

    awesome prompt !!!!!! thanks vry much :)

Similar Threads

  1. seperation of file contents
    By Ms.Ranjan in forum New To Java
    Replies: 5
    Last Post: 07-11-2008, 09:17 PM
  2. SWT Event Handling
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-30-2007, 12:21 PM
  3. Combo Box Event handling
    By smajidali26 in forum AWT / Swing
    Replies: 1
    Last Post: 11-29-2007, 05:57 PM
  4. problem with event handling!!!
    By ahdus in forum Java Applets
    Replies: 1
    Last Post: 11-17-2007, 06:24 PM
  5. Event Handling
    By luisarca in forum Sun Java Wireless Toolkit
    Replies: 5
    Last Post: 05-07-2007, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •