Results 1 to 5 of 5
Like Tree3Likes
  • 2 Post By Norm
  • 1 Post By Fubarable

Thread: GUI APIs and Input Events

  1. #1
    shadowayex is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default GUI APIs and Input Events

    I'm working on some of my own APIs for game development in Java as both a learning project and hopefully something I can carry through to an actual product. One of the APIs is something like an Input Registry. It is designed to keep track of key/mouse events and notify registered listeners when it's registry changes. I've noticed that different GUI APIs written for Java sort of handle their input events differently. I was wondering if there was a non-GUI API specific way to capture what key/mouse events are happening. I'd like to keep this lower level of the API as separate from specific GUI APIs as possible, so that I can use AWT, SWT, Swing, JFace, or whatever else is out there all on top of the same lower level API.

    Is this possible?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default Re: GUI APIs and Input Events

    You should be able to define your own events and have listeners register with your code. Then define a mapping from key and mouse events to your events. Your code listens for key and mouse events, maps the event to your event and calls the listeners for your events.
    Fubarable and shadowayex like this.

  3. #3
    shadowayex is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: GUI APIs and Input Events

    Well, since I'm not writing the GUI, and I'm don't want to force the user to use a certain GUI API, I'm confused as to how to make my code listen for input. As far as I know, in order for my code to listen for input events, it has to be added as a listener to a component of the GUI toolkit of the user's choice. I don't know what SWT or JFace use for events (I've only used Swing and little bit of raw AWT), but if they've defined their own, how would I go about making sure my listeners would work in all GUI APIs? Or am I going to have to limit what GUI APIs users can use?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: GUI APIs and Input Events

    You would write the model to be GUI library-agnostic. The listeners and GUI code would all have to be tailored to the GUI library that you're using.
    shadowayex likes this.

  5. #5
    shadowayex is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: GUI APIs and Input Events

    Ok, that makes sense.

    Thank you both.

Similar Threads

  1. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 01:22 PM
  2. SMS Java APIs
    By a_turingmachine in forum Advanced Java
    Replies: 0
    Last Post: 08-12-2008, 05:33 AM
  3. Java APIs
    By chagla in forum New To Java
    Replies: 1
    Last Post: 07-23-2007, 11:19 AM

Posting Permissions

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