Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Is it possible for a mouse listener to exist without a GUI interface?

  1. #1
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Is it possible for a mouse listener to exist without a GUI interface?

    I wanted to try something for a small program I'm writing. I'm trying to write a mouse listener that can detect if the right mouse button is pressed without having to write a gui. I've implemented the MouseListener class, but the event doesn't seem to fire if I don't extend JPanel or JFrame. Any suggestions?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,159
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default Re: Is it possible for a mouse listener to exist without a GUI interface?

    You might want to look into this: Toolkit (Java Platform SE 6)

    But you might also want to evaluate whether your approach is really the best one.

    Edit- I'm not sure the AWTEventListener will work without a GUI either, but it might be a good jumping off point. But like I said, you might just want to change your approach.
    Last edited by KevinWorkman; August 1st, 2011 at 11:35 AM.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Is it possible for a mouse listener to exist without a GUI interface?

    Thanks, but I implemented it in a different way.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Is it possible for a mouse listener to exist without a GUI interface?

    Can you post your solution?

Similar Threads

  1. PROBLEM CHECKING IF RECORDS EXIST OR DO NOT EXIST IN DATABASE
    By jimmyb0206 in forum JDBC & Databases
    Replies: 1
    Last Post: April 10th, 2011, 09:18 AM
  2. Urgent - File exist nor working
    By Bagzli in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 2nd, 2011, 03:09 AM
  3. The Problem With My Code Is That It Doesn't Exist Yet. (Help w/ Retarded Teacher)
    By DylanWilliams92 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 27th, 2010, 08:10 PM
  4. org.apache.derby does not exist?
    By disclaimer in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 30th, 2010, 04:58 PM
  5. How to handle quadratic roots that don't exist?
    By kairojya in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 28th, 2009, 12:21 PM