Results 1 to 2 of 2
  1. #1
    Drezir is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Calling Event Listener

    Hello,

    I have a question about how to call event listener from my own created method. Problem is that i have got listener for changing value on JSlider:

    Java Code:
    private void SliderDragged(java.awt.event.MouseEvent evt){creating new BasicStroke()}
    and then i have my own method for example callSliderDragged() where i need to call Event listener above.

    I have got 4 sliders which use same event listener SliderDragged - they change arguments for creating BasicStroke. BasicStroke also needs argument for dash sometimes and this can be load from jTextField's. So if value in jTextField is changed then i need to call SliderDragged. I know this could be done with common method but i am just interested if it is possible this way. Thank you all.
    Last edited by Drezir; 11-10-2014 at 10:04 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Calling Event Listener

    Instead of thinking about calling a listener method without triggering the listener, write a separate method and call that both from the listener and elsewhere.

    Also, learn to follow Java coding conventions: method names start with a lowercase letter.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Cant dispatch event or listener?
    By heatblazer in forum Advanced Java
    Replies: 5
    Last Post: 05-25-2013, 09:58 PM
  2. applet event listener
    By jobud9 in forum New To Java
    Replies: 4
    Last Post: 01-29-2012, 06:15 AM
  3. Implementing an event listener?
    By jammas615 in forum Java 2D
    Replies: 3
    Last Post: 07-04-2011, 04:15 PM
  4. how to add event Listener to Image
    By shane5317 in forum Java 2D
    Replies: 3
    Last Post: 03-13-2011, 11:36 AM
  5. Listener for SWT event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:04 AM

Tags for this Thread

Posting Permissions

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