How to intercept/capture MouseWheelEvent from JScrollPane

Suppose you want to have your own MouseWheelListener handle MouseWheelEvents that take place within a JScrollPane under some circumstances. Say, repurposing alt+wheel for zooming in/out, while leaving the wheel's normal behavior (scrolling content within the JScrollPane) when the alt key ISN'T simultaneously depressed during scroll activity.
What do you need to do to make it work?
Is it necessary to put a key listener on the JScrollPane that calls setWheelScrollingEnabled(false) whenever the alt key gets pressed, and calls setWheelScrollingEnabled(true) whenever the alt key gets released (and possibly registers and deregisters the JScrollPane as a MouseWheelListener as well)? Or is there some alternate strategy that would let me put my MouseWheelListener ahead of the JScrollPane in the event bubbling hierarchy so my MouseWheelListener would get a chance to handle the event first and zoom if isAltDown() == true, or cooperatively pass it along to the next MouseWheelListener in line instead of consuming the event if it's false?

Ideas:
1) Disable the wheel for the scrollpane (setWheelScrollingEnabled(false), as you suggested), capture the mouse wheel event as a separate event and process the scrolling manually (using addMouseWheelListener and calling either getVerticalScrollBar().setValue() to scroll, and some other method to zoom).
To capture the event, you could use
    Toolkit.getDefaultToolkit().addAWTEventListener(
        someListener, AWTEvent.MOUSE_WHEEL_EVENT_MASK  );or
    Component.addMouseWheelListener( someListener );2) Overload processMouseWheelEvent at some level (perhaps in your own extension of JScrollPane, though you may have to do it somehwere deeper) and pick out the alt combinations before calling super.ScrollPane.processMouseWheelEvent

Similar Messages

  • How to remove JTable header from JScrollPane?

    Hi!
    Does anyone know how to remove the JTable header from the JScrollPane the table is placed in? I tried calling
    scrollpane.setColumnHeader( null ) and
    scrollpane.setColumnHeaderView( null )
    but none of the above worked...
    Thanks!
    Fil

    Hi,
    The easiest way to do this is to put an extra layer between the table and the scrollpane as follows:-
    JPanel p = new JPanel(new BorderLayout());
    // Add it to the north rather than center so that the table background color
    // won't cover the empty part of the view port.
    p.add(table, BorderLayout.NORTH);
    JViewport v = tableScroll.getViewport();
    v.setView(p);
    where table is your JTable and tableScroll is your JScrollPane.
    Hope this helps,
    Ian

  • How can I Capture screen from command line

    When I start FME from command line it automatically capture
    from first camera
    But I want it start capture form screem automatically
    or I want to start 2 capture progress
    1 form camare
    2 form screen
    Thanks

    I don't print from the command line, so I don't know this off the top of my head. There are instructions for doing this in your CUPS documentation. Read Chapter 2 & 3 here:
    http://localhost:631/sum.html

  • How can I capture input from a separate window?

    Hi there.
    I've a question about java outputting data to the System output stream.
    What I have is 2 classes - Gui and GuiSimulator.
    The Gui has an update method that sets a variable.
    The GuiSimulator class is a static nested class of Gui that implements runnable.
    My class Gui looks like:
    public class Gui
        private String val;
        public void setVal(String value)
            this.val = value;
        public static void main(String... args)
                Gui gui = new Gui();     
                GuiSimulator sim = new GuiSimulator(gui);
                Thread t = new Thread(sim);
                t.start();
                //print out welcome message
                System.out.println("Please enter a name for the gui");
    }and my class GuiSimulator looks like:
    public class GuiSimulator implements Runnable
            private final Gui guiInstance;
         public GuiSimulator(Gui guiInstance)
              this.guiInstance = guiInstance;
         public void run()
              Scanner scanner = new Scanner(System.in);
              while(true)
                        //read some input
                        System.out.print("Enter some input: ");
                        String inputStr = scanner.nextLine().trim();
                        guiInstance.setVal(inputStr);
                        System.out.println("Value set in gui");
    }The issue I am having is that when the GuiSimulator runnable is started from main within class Gui,
    it outputs all its output to the same window as the Gui instance.
    What I would really like though, is to be able to have GuiSimulator capture it's input and display it's output
    in a seperate console window to that of Gui.
    Is this even possible?
    If not, is there a workaround that would allow maybe each class have a main method, and I
    could perhaps pass a gui instance that is running in the JVM to my main method of GuiSimulator?
    I hope there's a way. I'm using eclipse by the way.
    Thank you for you help.

    If I remember my console knowledge correctly, when executing a java application, the console the application is launched from is tied to that application's JVM. As a result, any console I/O for a java application is restricted to the JVM-launching console window. So no, I don't think it is possible in your current application's state to capture input in one console and output it in another.
    While I haven't looked into something like this all that much, you may want to look into the topic of RMI. If memory serves me, you should be able to launch your GUISimulator as a second java application, and use RMI design to remote calls between your GUI and GUISimulator. I could be totally wrong on this, though, so I would wait to see what some of the gurus have to say.

  • How can I capture photos from iMovie 11?

    I want to capture a photo from a video clip.  The instructions I've found online do not seem to work with iMovie 11.  Does anyone have a suggestion?

    First, get an app called MPEG Streamclip, which is free. (google MPEG Streamclip from Squared 5)
    Open MPEG Streamclip.
    In iMovie, select the clip you need. Then, right-click/Reveal in Finder.
    Drag this clip into MPEG Streamclip
    In MPEG Streamclip, move the playhead to the frame you want.
    In MPEG Streamclip, click FILE/EXPORT FRAME.
    Choose JPEG, TIFF, or PNG and give it a name.
    You can then drag this photo into iPhoto.
    Here is a video I made that steps through this...
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • How do I capture video from canon d5 mark II to fcp using usb connection

    I have always imported video to fcp via firewire using my tape cameras but soon I will have to make the jump to non linear cameras eventually as tape becomes obsolete. I haven't got a non linear camera but would like to know if there's a simple way to upload video footage with a camera like the 5d or similar non linear video cameras. Also, I'd like to know if it is possible to select the in and out points before importing like you do with tape devices so that you don't have to download all the footage shot. Thanks for any advice.

    Attach camera via USB or put card in card reader.
    Go to FCP, and go to the Log and TRANSFER window.
    If FCP recognizes the card, you will see your clips listed on the left.
    You can view them, set Ins and Outs, and import just what you want.
    Once you choose a section of video and import it, FCP converts (transcodes) from its original camera format to Apple ProRes422 - a more edit friendly video file.

  • How do I capture footage from camera to an external drive using a macbook

    i'm trying to use my external drive to store my project because otherwise i don't have enough memory. however, there is i think only one firewire port on my macbook. if i connect the camera directly to the external drive it doesn't seem like fce can find it in easy set up. how do i connect my macbook, camera, and external drive so that i can work off my external drive? anyone?

    I have the same query with my macbook which only has 1 firewire 400 port.
    I haven't bought an external drive yet, but want to buy the one that has the right connections.
    After you connect the camera to the ext. hard drive what connection do you use between hard drive and macbook? Ethernet?
    Also, any recommended hard drives, I've heard Lacie are a good one but which model?
    Thanks in advance.

  • How Can I Capture Images from Web Page

    When I use Create PDF from Web Page, Acrobat downloads all the text and backgrounds and everything else except the images / photos. Instaed of the photos I only get hypertext links to those photos. I have tried every setting I could find to no avail. What am I missing?
    Cheers, Murray

    Hi
    You can try robolab for Labview, too. Its multimedia vis will run in Lv6.1 and USB webcam
    Search these forums for link.
    Cheers
    Alipio
    "Qod natura non dat, Salmantica non praestat"

  • How can i capture video from the ipad?

    Forgive me im not sure of the technical terms but Is it possible to do a 'video screengrab' from the ipad for video editing. I'm looking to promote a game i've made and would like to produce a trailer for marketing purposes.
    Thanks in advance
    S

    For a FireWire 400 camera, you will need a Thunderbolt to FireWire 800 adapter and FireWire 800 to 400 adapter or cable.
    TB to FireWire 800 adapter > http://store.apple.com/us/product/MD464ZM/A/apple-thunderbolt-to-firewire-adapte r
    and a FireWire 800 to 400 adapter > http://eshop.macsales.com/item/Newer%20Technology/FIR1369AD
    or a FireWire 800 to 400 cable > http://eshop.macsales.com/item/Newer%20Technology/1394B96036/
    For a S-Video or RCA camera, you will need a http://www.roxio.com/enu/products/easy-vhs-to-dvd/mac/overview.html or similar Mac compatible adapter.

  • How to install capture drivers from cd?

    Hello,
    i just bought the NX7950GT-VT2D512EZ-HD card and installed it. it should have video in but when i click on the "install capure drivers" option on the cd menu nothing happens. everthing else i click on in the menu works. the pop up information says that you can only install the drivers if your card have the video in option. what could be the problem ? and what could i do to fix it?
    (windows xp, core2duo 2,13, 2gb DDR2 FSB800, ASUS So. 775 P5B-E Plus).
    thanks for any help!

    latalante,
    Download and install the last nVidia ForceWare & WMA Drivers
    Then take the MSI CD, set it on your desk, go to the kitchen and pour your favorite cold drink. Come back to your desk and put your drink on the CD. That is about all they are good for.
    Take Care,
    Richard

  • Capturing data from a RS232 device

    how do I capture data from an RS232 device to my APEX application. Precisely, I am using a barcode scanner and I need to know how to get the barcode data into an item (say P12_barcode) in my application. I have tried the keyboard wedge and the problem is that I have to set the input focus each time I need to collect the barcode of an item, so I have to switch to RS232 mode but how do I get this barcode data now?
    Please HELP...

    Thanks a trillion for this reply! wether your reply was helpful is an understatement in this matter!
    That is the type of Barcode scanner I am using man... they call it USB Keyboard emulation. It scans into note pad, word processors and text items freely.
    In my design for a solution to this problem, I have on paper, your type of solution but I lack the ability to set the focus on the desired Text Field when my cash_sales page loads.
    Secondly you said "I did have to set it to include a "Enter" after each scan" that touched upon another bug in me: I had always wanted the form to submit after each scan so that my procedure can use it against the items database and display the item in my Current Transaction Report. How did you set it to include a "Enter" after each scan? Is it on the scanner or at the page item level?
    Precisely I am using Metrologic MS9520 barcode scanner a.k.a Honeywell MS9520 barcode scanner!
    If I can set a cursor in my Px_Barcode text item after loading my CASH_SALES page and automatically submit the page after a scan(without clicking any button) then my nightmare is over...and you become my Virgo 2009 Hero.
    Happy September :)

  • Capture keyboardevent from Windows

    Hi, is there any way how can I capture KeyboardEvent from Windows using AIR? because I want to make my application to be able to popup from tray when I press some keys in Windows (for example CTRL+ALT+SHIFT+T) but I was able to catch KeyboardEvent just on stage...
    thanks

    Hi, you cant do that without focusing on your window, you have to use a third party program.

  • How can I download video from a Canon ZR30 video camera to my IMac.  I bought Elgato Video Capture, but the connections do not match.  There is no white female end in the camera.  Also, the red and yellow connections are loose at the camera end.

    How can I download video from a Canon ZR30 video camera to my IMac?  I have Elgato Video Capture, but the provided connectors are loose in the camera and the camera does not have a white female end.  No signal shows up on the computer when I connect the red and yellow connectors.

    Broken solder joints on the camera me thinks!!
    sorry

  • In v.11, how can I capture video but not audio from a camera?

    In v.11, how can I capture video but not audio from a camera?

    Rodney
    I see what you mean....Premiere Elements 10 appears to be the last version that had options for the user to select Capture Video and/or Audio in the its Capture Window.
    If you are doing DV data capture firewire into the Premiere Elements 11 Capture Windows and want a final file without audio and you cannot do this at the camera level, then consider....
    1. Do the Capture "to the Timeline" - video linked to audio result on the project's Video Track 1
    a. Right click the Timeline DV AVl and select Delete Audio and then edit accordingly.
    or
    b. Import the DV AVI but, when you go to export it, in the export settings, remove the check mark next to Audio so that the export contains only the video portion.
    Publish+Share/Computer/AVI with Presets = DV NTSC Standard
    Please let us know if any of that worked for you.
    Thank you.
    ATR

  • On my mac, photoshop cc "save as" removes capture date from exif data. How do I prevent this?

    On my mac, photoshop cc "save as" removes capture date from exif data. How do I prevent this?

    You had to reinstall CS6 after cancelling the CC as both were from the same Adobe ID. You can always use & keep both CC & CS6 together.
    Please refer to the blog:
    Can I install both CS6 and CC apps on my computer? « Caveat Lector
    Other references are :
    Creative Cloud Help | Install, update, or uninstall apps
    What is the difference CS6 & CC Versions?
    Regards
    Rajshree

Maybe you are looking for

  • Loops there but not

    Why do loops appear in the browser, but don't play when I drag them into tracks?

  • Printing PS3 on Brother DCP6690CW

    Hi all! Thanks for reading this! Am really not sure whether this is the right forum for such a query... Getting straight to the point, my issue is the following: I am part of an organisation where we use an operating system called Advantage Windows (

  • Javascript to check points

    Hi I am new to use the scripting in Acrobat. Ive few checkpoints to validate the document. Is it possible to have a javascript to run in acrobat? Can anyone guide me? Thanks in advance Jothi

  • Copy paste a cat face

    Hello, I am trying to copy and paste a cat face once I've used the clipping mask technique. Once I am done pasting the Cat face it wont copy just the part that has been clipped, it copies the whole entire selection I made. check the picture attached

  • ZEBRA PROGRAMMING FOR SHIPPING LABEL

    Hi gurus, i have one assignment for creating shipping label using zebra programming into SAPSCRIPT. page size is 5 inch X 7 inch. I also want to draw a circle and in that  circle i want to write P\B . i.e. no lead symbol. can anybody give me the samp