Listening for multiple keypresses simultaneously

I'm trying to move a rectangle around with arrow keys.
The current code of keyPressed method is
     public void keyPressed(KeyEvent e){
/*           switch(e.getKeyCode()){
               case 37: x=(Math.max(0,x-3));break;
               case 38: y=Math.max(0,y-3); break;
               case 39: x=Math.min(200,x+3);break;
               case 40: y=Math.min(200,y+3);break;
          int a = e.getKeyCode();
          if(a == 37){x=Math.max(0,x-3);}
          if(a == 38){y=Math.max(0,y-3);}
          if(a == 39){x=Math.min(200,x+3);}
          if(a == 40){y=Math.min(200,y+3);}
          repaint();
     }The problem is that when pressing multiple keys at the same time only one registers.
So how do I register multiple key presses ad change x and y accordingly?
thank you

It seems to me that the problems mentioned in that link with the "hold" could be solved with using a state flag set on keyPressed and then reset on keyReleased. When you release even one you should get the keyReleased event and until then, you should be in a hold state.

Similar Messages

  • Use 1 listener for multiple database in a server

    hi guys,
    just want to check whether this is the right way to configure my Listener.ORA . I am using 1 listener.ora to listen for incoming request connection from remote client. There are multiple databases installed in a server.
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ora03)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = O11R2)
    (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
    (SID_NAME = O11R2)
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = O10G)
    (ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
    (SID_NAME = O10G)
    )sorry i am reading about it so did not install another database to test out. Just thinking in the line that it mention that the list of SID is refering to the multiple database that is installed in a server and i am using 1 listener.
    Please further advice.

    Shivananda Rao wrote:
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ora03)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = O11R2)
    (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
    (SID_NAME = O11R2)
    (SID_DESC =
    (GLOBAL_DBNAME = O10G)
    (ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
    (SID_NAME = O10G)
    )Please use as above. You can have one listener for multiple databases.right right so it the pattern goes like this:
    SID_LIST_LISTENER =
         (SID_LIST =
              (SID_DESC =
              (GLOBAL_DBNAME = AAAA)
              (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
              (SID_NAME = AAAA)
              (SID_DESC =
              (GLOBAL_DBNAME = BBBB)
              (ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
              (SID_NAME = BBBB)
         )thanks !

  • One Listener for multiple things?

    Is is OK to use on listener for multiple events on the same object?
    I have this for a FLV component and it seems to work. Is that legit?
    var listenerObject:Object = new Object();
    listenerObject.complete = function(eventObject:Object):Void {
        trace("End of this video!!!!");
    myVideo.addEventListener("complete", listenerObject);
    listenerObject.stateChange = function(eventObject:Object):Void {
        trace("stateChange just occurd!!!");
    myVideo.addEventListener("stateChange", listenerObject);
    Thanks a lot for any info!!!

    Yup no problem. However I would group my listener object properties close together.
    listenerObject.complete=function(e:Event){
    // blah blah
    listenObject.progress=function(e:Event){
    // blah blah blah
    And so on. If they end up separated you most likely will forget over the course of time and then when you come back you might delete the object after you use it for one event and forget that it has others.

  • Can I search for multiple images simultaneously in Aperture?

    Can I search for multiple images simultaneously in Aperture?  For example, search for 'Image2.jpg, Image3.jpg, Image5.jpg' by image name, out of different folders? 

    dusan -- your best procedure is likely to be to type the first file name (without extension) in the search field of the Photos View, and then mark that file either with a Flag or a color label.  (You might clear all Flags prior.)  If you have a lot of images or a slow computer (or both ) you may have to wait a few seconds.  Aperture will show "Loading ... " on the left side of the tool strip while it churns through your images.
    Then hit backspace twice, and type "60".  Mark the file found.
    Repeat with variations.
    Then go to Flagged view, or filter the whole Photos view for the color-label you used.

  • Remove stage listener for multiple movieclips

    I would like to completely remove personalized stage listeners, for each movieclip as soon as they are placed where they need to be, but the listeners remain every single time a new clip is dragged.
    Thank you for any help!
    function clickToDrag(targetClip:MovieClip):Function {
              return function(e:MouseEvent):void {
                        startingPosition[targetClip.name] = new Point(targetClip.x, targetClip.y);
                        targetClip.startDrag(false, new Rectangle(0,0,800,600));
                        setChildIndex(targetClip,numChildren - 1);
                        trace('clickToDrag function invoked\ntargetClip: ' + targetClip.name + '\startingPosition: ' + startingPosition[targetClip.name] + '\n\n');
                        stage.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    /*          releaseToDrop
              @function          stopDrag for current clip, if dropped off stage, returns to recorded beginning location
              @param                     targetClip:MovieClip
              @param                     startPosition:int
              @returns          event:void
    function releaseToDrop(targetClip:MovieClip):Function {
              return function(e:MouseEvent):void {
                        targetClip.stopDrag();
                        trace('releaseToDrop function invoked\ntargetClip: ' + targetClip.name + '\n\n');
                        stage.removeEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
                        stage.addEventListener(Event.MOUSE_LEAVE, mouseGone);
                        function mouseGone () {
                                  TweenLite.to(targetClip, .2, { x: startingPosition[targetClip.name].x });
                                  TweenLite.to(targetClip, .2, { y: startingPosition[targetClip.name].y });
                                  //toggle comments to ease or not ease back to startingPosition
                                  //targetClip.x = startingPosition[targetClip.name].x;
                                  //targetClip.y = startingPosition[targetClip.name].y;
                                  stage.removeEventListener(Event.MOUSE_LEAVE, mouseGone);
                                  trace('releaseToDrop function invoked\ntargetClip dragged out of bounds: ' + targetClip.name + '\n\n');
    /*          checkTarget
              @function          checks if current clip is dragged to drag1target(dock), updates boat weight and waterline, remove listeners
              @param                     targetClip:MovieClip
              @param                     lbsAmount:int
              @param                     targetLocation:MovieClip
              @returns          event:void
    function checkTarget(targetClip:MovieClip,lbsAmount:int,targetLocation:MovieClip):Function {
              return function(e:MouseEvent):void {
                        if (targetClip.hitTestObject(drag1target)) {
                                  targetClip.x = targetClip.x;
                                  targetClip.y = targetClip.y;
                                  drop.play();
                                  TweenLite.to(targetClip, .5, { alpha: 0, onComplete:fadein });
                                  function fadein() { TweenLite.to(targetLocation, .5, { alpha: 1 }); }
                                  noMC.waterlineMC.y = noMC.waterlineMC.y - 3;
                                  lbs -= lbsAmount;
                                  lbsTxt.htmlText = lbs + "<font size='16'>lbs</font>";
                                  targetClip.buttonMode = false;
                                  targetClip.mouseEnabled = false;
                                  targetClip.removeEventListener(MouseEvent.MOUSE_UP, checkTarget);
                                  targetClip.removeEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
                                  /* TODO: Issue with stage listener for every clip, opportunity to handle programmatically? */
                                  /* check to see if eventListenter is still present */
                                  if(targetClip.hasEventListener(MouseEvent.MOUSE_DOWN)) {
                                            trace(targetClip.name + ' still has MOUSE_DOWN event listener');
                                  if(targetClip.hasEventListener(MouseEvent.MOUSE_UP)) {
                                            trace(targetClip.name + ' still has MOUSE_UP event listener');
                        } else if (borderMC.hitTestPoint(targetClip.x, targetClip.y, true)){
                                  /*targetClip.y = startingPosition[targetClip.name].y;
                                  targetClip.x = startingPosition[targetClip.name].x;                              */
                                  TweenLite.to(targetClip, .2, { x: startingPosition[targetClip.name].x });
                                  TweenLite.to(targetClip, .2, { y: startingPosition[targetClip.name].y });
                        } else {
                                  /*targetClip.y = startingPosition[targetClip.name].y;
                                  targetClip.x = startingPosition[targetClip.name].x;          */
                                  TweenLite.to(targetClip, .2, { x: startingPosition[targetClip.name].x });
                                  TweenLite.to(targetClip, .2, { y: startingPosition[targetClip.name].y });

    i will try to show you a way that might help you to understand how the event-model in as3 is meant to work.
    look at this code:
    //with a MovieClip "DragClip" in the Library exoported for ActionScript
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    for (var i:int = 0; i<10;i++){
        var mc:DragClip = new DragClip();
        addChild(mc);
        mc.mouseChildren = false;
        mc.addEventListener(MouseEvent.MOUSE_DOWN, dragStart);
        mc.addEventListener(MouseEvent.MOUSE_UP, dragStop);
        addChild(mc);
    function dragStart(e:MouseEvent):void {
        e.currentTarget.startDrag();
        trace("dragging started");
    function dragStop(e:MouseEvent):void {
        e.currentTarget.stopDrag();
        trace("dragging stopped");
        e.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, dragStart);
        e.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, dragStop);
    //it places hundred Movieclips on the stage
    //makes them draggable
    //but after they are dragged once
    //they stay in place

  • Configure Listener for Multiple IP's???

    I need to know how to configure my listener on a Windows 2000 Advanced Server using Oracle 8i to allow for the following conditions:
    1) I have 4 NIC'S in my server and I have 1 different IP address on each NIC.
    2) Stations will connect to Oracle via those 4 different IP's/NIC'S for load balancing of the NIC'S.
    3) There is only 1 SID used for my database.
    Any suggestions of how to configure the listener?
    Any Help GREATLY appreciated!!!
    mailto:[email protected]

    Can you use the idea posted here?
    You only have 2 options if you want to use remote desktop on multiple pc's on the same lan. Change the listening port, or forward an external port to a different internal port. Don’t enable upnp, there’s no need for it and it will just cause more problems than its worth. why would you want an application opening ports on your firewall without you knowing it? Just change the listening port on pc 2 to 3390, pc 3 to 3391. Then forward these ports to each respective ip address (should be static ips). and you are done. When you want to connect to pc 1 you type {your ip} and it will connect to pc 1. For pc 2, you type {your ip}:3390. pc 3 {your ip}:3391.
    http://support.microsoft.com/kb/306759
    Westell 6100 modem/router; Linksys WRT54GL v1.1 router firmware 4.30.9; Linksys WPC54G v2 Notebook Card; CenturyTel DSL using PPPoE

  • Show file size in Cell Extras? (Either Compact or Expanded, or anywhere in Grid for multiple images simultaneously)

    I've searched and seen several suggestions saying to change Metadata to Exif & IPTC to see the file size, but that's for only one image at a time. Under Cell Extras (both Compact and Expanded) I see options for Megapixeps, Cropped Dimensions, File Name, Extention, and a bunch of other options, but no file size. I suspect this is because file size isn't a metadata field and simply a file attribute (that may be incorrect, but regardless...) is there really no way to have file size visible in the thumbnail cells in Grid view in the Library? I'm trying to reduce redundancy and viewing file size of multiple images at a glance based on my Library Filter criteria would be a huge help. Thanks to anyone who can help sort me out!

    Sure. I have a catalog with 22,000 images indiscriminately imported from hundreds of folders and multiple drives from this year alone (partially lost a RAID array to a corrupt index and recovered a dump of the files so I'm terribly disorganized juggling emergency redundancy backups wherever I had 50 gigs here, 100 gigs there, and working to clean up and organize my photos one year at a time ), including raw, jpg, websized jpg, png, tiff and psd (flattened and with layers/adjustments) and am now trying to identify my keepers and delete unnecessary files. I have 22 terabytes of personal files and photography spread chaotically and while I now have proper discipline when saving variants, I didn't always and want to remove unneeded, rejected, and duplicate images. I don't expect to be caught up for months or longer depending on my free time and sanity. Unfortunately, it's not as simple as keep the raw delete the rest. Sometimes I have multiple PSD documents with different version names and edits, sometimes with multiple layers, and I have to use a variety of information to identify which one is indeed the correct one to keep...or open them all/both.
    Often, file size can be an indicator for me and aids in making the decision more quickly. For instance between 2 psd files with the same Megapixles I'm often able to identify the flattened version vs the layers intact version by file size if it wasn't properly noted in the filename, which unfortunately due to a combination of bad or evolving practices and being tired or rushed happens more often than I'd like to admit. One I just came across that brought me here searching was 3 similarly named and appearing PSD files of a panorama, all with the same MP/dimensions. One was flattened, one was the original stitch, and one was flattened with a few masks, adjustments, and an extra layer, and being the one I'd want to keep. Filesize helped me quickly identify which was which. Also sometimes dimensions are misleading, like when a panorama is first created and uncropped, its dimensions are larger, but a tighter cropped image with multiple layers and a larger file size indicates to me that it is newer and more finished, even though smaller dimensions typically indicates a crop and may not be a 'master' copy. Additionally, 2 images with different names but the exact same file size are very likely duplicates (at least in my workflow) but 2 similarly looking images with the same dimensions could be retouched/not, sharpened/not, have noise reduction/not, and I'd have to view them in detail to determine if they were in fact identical. For my purposes (since these are my personal fine art images & I have the raw files incase I occasionally mess up) I'm often willing to trade an educated guess for my time. Seeing identical file sizes on 2 apparently similar images is good enough for me to delete one.
    I can select them individually and check...it's not a horrific problem. But it would save me time so I was hoping I had simply missed how to view that. My reasoning is 'why not' have the option available with all the others? Me personally, I don't care about megapixels when I already have the dimensions, that's just redundant and honestly much less helpful than LxW. File size would be an additional tool I would use, though. There are other examples but the main thing is that I do spend time checking filesize, and specifically when comparing multiple images, so having it displayed in the cell would be a time saver for me.

  • Single Listener for multiple Dbs

    Hi,
    I have configured one listener (dev) for the two DBs--Dev and orcl.When i see the services status in lsnrctl i get the below mentioned:
    LSNRCTL> services
    Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:0 refused:0
    LOCAL SERVER
    Service "dev" has 2 instance(s).
    Instance "dev", status READY, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:1 refused:0 state:ready
    LOCAL SERVER
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:1 refused:0 state:ready
    LOCAL SERVER
    Service "orclXDB" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
    "D000" established:0 refused:0 current:0 max:1002 state:ready
    DISPATCHER <machine: ACER-E4EC306ECF, pid: 3364>
    (ADDRESS=(PROTOCOL=tcp)(HOST=acer-e4ec306ecf)(PORT=1527))
    The command completed successfully
    Now whenever i use the connect string in sqlplus as orcl ,it wont allow me to connect to the orcl DB and gives the error ORA-12514 unable to resolve the service given in service_names..which is obvious since the service name is dev .ALso in pfile of DB orcl ,i hv specified the parameter service_names=dev since the listener name is dev and instance_name as orcl.
    Now the real problem is whevenever i use the connect string as dev,it connects me to the orcl DB.My problem is how would the users connect to the dev DB.I m using dynamic service registration.
    Thanks in advance.

    Hi,
    What is your listner.ora nad tnsnames.ora file says ?? put them on the board .
    Thanks
    Alok.

  • Single Listener for multiple controls

    Assuming I have 3 Slider Controls representing 3 different properties of an Object. How could I use a Single Listener/Handler to track the changes from all 3 sliders.

    Simply attach the same ChangeListener to all three sliders, but instead of looking at the new/old value parameters, just query all 3 of the sliders for their current values and use those.
    package hs.javafx;
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.Scene;
    import javafx.scene.control.Slider;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class ThreeSliderTest extends Application {
      public static void main(String[] args) {
        Application.launch(args);
      @Override
      public void start(Stage primaryStage) throws Exception {
        VBox vbox = new VBox();
        final Slider slider = new Slider(0, 100, 15);
        final Slider slider2 = new Slider(0, 100, 65);
        final Slider slider3 = new Slider(0, 100, 55);
        ChangeListener<Number> changeListener = new ChangeListener<Number>() {
          @Override
          public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number value) {
            System.out.println("R,G,B = " + slider.getValue() + "," + slider2.getValue() + "," + slider3.getValue());
        slider.valueProperty().addListener(changeListener);
        slider2.valueProperty().addListener(changeListener);
        slider3.valueProperty().addListener(changeListener);
        vbox.getChildren().addAll(slider, slider2, slider3);
        Scene scene = new Scene(vbox);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

  • Is it possible to compile NVIDIA for multiple kernels simultaneously?

    Hi all,
    First, the reference is http://wiki.archlinux.org/index.php/NVI … tom_kernel, as well as a small discussion I started at http://aur.archlinux.org/packages.php?ID=20410.
    Basically, currently the nvidia-beta (and I'm sure the rest of the nvidia scripts) use `uname -r` to obtain the current kernel name, which is then used for the rest of the PKGBUILD. Its relatively trivial to alter that to the name of whichever kernel, meaning there's no problem compiling nvidia.ko for kernel26-ice from within kernel26 itself, and to alter the name of the package so that your nvidia-beta package does not need to be over-written (you then have two nvidia.ko, each for their own kernel.
    My question is, is it possible for a single PKGBUILD to compile nvidia.ko for all kernels currently installed (probably through looking at either /lib/modules or /usr/src)? This would mean only one maintainer is needed for nvidia-beta or nvidia-17xx or whichever series, and the same PKGBUILD could be used on any system, even those with multiple kernels.
    I'm not very familiar with the limitations of PKGBUILDs, or the rules governing what they may or may not do (for example, accessing and checking the machine itself outside the fakeroot?), so this may be nonsense, if so feel free to point it out. Another idea would be for a simple bash script to create as many PKGBUILDs as required, based on the most recent nvidia-beta PKGBUILD, simply sed-replacing uname -r with the appropriate kernel names and modifying the PKG name.

    Hi,
    it's not difficult to do but I DO NOT recommend to do it (see my notes below the code).
    PKGBUILD
    pkgname=nvidia-beta
    pkgver=185.18.04
    pkgrel=1
    pkgdesc="NVIDIA beta drivers for kernel26."
    arch=('i686' 'x86_64')
    [ "$CARCH" = "i686" ] && ARCH=x86 && NV=0
    [ "$CARCH" = "x86_64" ] && ARCH=x86_64 && NV=0
    provides=(nvidia=${pkgver})
    url="http://www.nvidia.com/"
    depends=(kernel26 nvidia-utils-beta)
    conflicts=('nvidia-96xx' 'nvidia-71xx' 'nvidia-legacy')
    license=('custom')
    install=('nvidia.install')
    source=(ftp://download.nvidia.com/XFree86/Linux-$ARCH/${pkgver}/NVIDIA-Linux-$ARCH-${pkgver}-pkg${NV}.run)
    md5sums=('95b67e6f17cc54d36ae2743df76c9f6d')
    [ "$CARCH" = "x86_64" ] && md5sums=('33967a6d452c562bb8af02b0734ebf22')
    build()
    # Read list of installed kernels
    KERNELS=`ls -1 /lib/modules`
    # Extract the nvidia drivers
    cd $startdir/src/
    sh NVIDIA-Linux-${ARCH}-${pkgver}-pkg${NV}.run --extract-only
    cd NVIDIA-Linux-${ARCH}-${pkgver}-pkg${NV}
    cd usr/src/nv
    ln -s Makefile.kbuild Makefile
    # Now build modules for each kernel
    for KERNEL in $KERNELS; do
    echo "Building for ${KERNEL}"
    # Compile the module
    make SYSSRC=/lib/modules/${KERNEL}/build module || return 1
    # Install kernel module
    mkdir -p $startdir/pkg/lib/modules/${KERNEL}/kernel/drivers/video/
    install -m644 nvidia.ko $startdir/pkg/lib/modules/${KERNEL}/kernel/drivers/video/ || return 1
    # Clean
    make clean || return 1
    done;
    nvidia.install
    # arg 1: the new package version
    post_install() {
    KERNELS=`ls -1 /lib/modules`
    for KERNEL in $KERNELS; do
    depmod -v $KERNEL > /dev/null 2>&1
    done;
    # arg 1: the new package version
    # arg 2: the old package version
    post_upgrade() {
    post_install $1
    rmmod nvidia || echo 'In order to use the new nvidia module, exit Xserver and unload it manually.'
    # arg 1: the old package version
    post_remove() {
    KERNELS=`ls -1 /lib/modules`
    for KERNEL in $KERNELS; do
    depmod -v $KERNEL > /dev/null 2>&1
    done;
    op=$1
    shift
    $op $*
    PS: I haven't test it because I don't use multiple kernels
    But be aware of possible problems. Some modifications may influence kernel functionalities, so once you compile a driver for kernel26-xyz on kernel26-zyx the module may not work on kernel26-xyz or may cause unexpected issues.
    You also should not (you possibly even won't be able to) build module for different release version (eg. build for 2.6.28 on 2.6.29) due changes in kernel headers.
    I'm also not sure if it is safe to generate module dependencies for another kernel then you are currently running.
    As you can see above, it is not problem to make such a PKGBUILD, but it also brings too many problems and it's too dangerous that it is better to stay at current model "module package for each kernel". So if you want to you may try to use this PKGBUILD, but I strictly warn everyone else that it may cause more harm then use so don't blame me if something goes wrong. You were warned .
    Last edited by ProgDan (2009-04-30 13:48:06)

  • Using java to listen for a keypress when the program is not in focus

    I want to set up a program where no matter what other program I'm using, when I press Ctrl+F1 my program will take focus and run another function or two. Is this possible and if so how can it be done?
    Thanks.

    Ok Mr. Smartass...Ok
    I'm building a browser that is always open, and when
    a user presses Ctrl+F1 (notice, just those two keys,
    I don't care what else they press...) the browser
    will open up. That way, you don't have to wait for it
    to load all the time.You have two ideas here. One is having a universal key map that always gets ctrl-f1 sent to your app. The other is a program that is constantly running so that you don't have to wait for it to open up. The former is not possible (and this is a good thing) As warneria and I have been saying, it is bad design for an app to try to force an OS to implement this kind of feature.
    If you're not going to help please don't post at all;
    it's a waste of time for both you, me, and anyone
    else who may need help on the same subject. Why wouldBelieve it or not, I am helping you.
    See
    http://www.google.com/search?hl=en&lr=&q=programming+code+side+effects
    and
    http://www.faqs.org/docs/artu/ch04s02.html
    "Doug McIlroy's advice to �Do one thing well� is usually interpreted as being about simplicity. But it's also, implicitly and at least as importantly, about orthogonality."
    anyone in their right mind who's trying to steal
    people's passwords come out and say, "I'm not trying
    to steal people's passwords!"wait, your question is why would someone trying to steal passwords say I'm not trying to steal passwords? I think duplicitous people in their right minds might try to trick you that way.
    Beyond that, even if you're not a malicious hacker - and I am sure you are not - if someone posts a solution to your problem, malicious coders then will have learned how to do it. If you think you're programming or using these forums in a bubble, you are not.

  • Listening for several input queues

    Hi!
    My application receives messages from several queues. I also need to know for each message what queue is it from. That's why I had to define separate MessageListener's for each queue. So each queue has its instance of MyListener (see below). I synchronized the onMessage method on static Object, so only one message from all queues is processed in given moment:
    MyListener implements MessageListener
    static Object object;
    onMessage (Message message)
    synchronized (object)
    //process
    The problem is, that while processing current message, new messages (I suppose one per queue) are already taken from the queue and waiting to be processed. Thus if my application will shut down I will loose at least one message per queue. I'd like to hear your suggestions.
    Thanks.

    Rather than creating multiple listeners, you can write one listener with a case like structure:
    public void onMessage(Message m) {
    Queue queue = (Queue) m.getJMSDestination();
    String name = queue.getName();
    if (name.equals("q1")) {
    // what the message listener for q1 would do ...
    } else if (name.equals("q2")) {
    // etc
    You can then register this message listener for multiple queues. The motivation for doing this was a requirement that the execution of the message listeners had to be serialized. You can also achieve this by creating the queue receivers from the same session.
    If there is no serialization requirement it's a matter of taste whether you prefer the combo listener above or multiple listeners. In this case you also can create the sessions from different connections to get concurrent message dispatch and possibly better performance.
    - Bjarne.

  • How to configure multiple listeners to listen for the same instance.

    Hello everyone,
    I am running oracle database 11g and I want information regarding how to configure multiple listeners to listen for the same database instance. Actually I know how to configure more than one listener but the main thing that I am confused about is when we create listener.ora file, do we have to statically register the database instance with both the listeners or the instance will register itself with both the listeners.
    According to my knowledge the instance will register with the listener specified by LOCAL_LISTENER parameter and we cannot have more than one value for this parameter.
    Please only give detailed answers with example as I am tired of simple answers with details that I already know.

    Hello,
    Yes, it can make sense to have several listener for one Oracle instance. For instance you may have one listener for the applications another listener for DBA administration tasks as well as one listener dedicated to dataguard broker. It is not possible to have several listeners listening on the same IP and Port.
    By default the database try to automatically register to a listener on port 1521. To instruct the instance to register to a specifc list of listeners you can add in the init.ora the local_listener parameter with an alias definition:
    i.e
    local_listener=MY_SET_OFF_LISTENERS
    in your tnsname.ora add an entry called:
    MY_SET_OFF_LISTENERS_LOCAL= (ADDRESS_LIST=
    (ADRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1530))
    (ADRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1531))
    (ADRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1532))
    In this sample your instance will register to three listeners listening on respectively port 1530, 1531 and 1532
    If you want your clients can be balanced over the 3 listeners

  • Is there a way to simultaneously add text to Comments field for multiple files?

    Is there a way to simultaneously add text to Comments field for multiple files? I know I can use Option+Comman+i to bring up the Inspector window but it doesn't have a Comments field. For example, in iTunes you can select multiple files and change metadata for any field simultaneously and easily yet when it comes to the Comments field in the Finder, this seems to be missing.
    In our production environment, Comments field is important because we place notes about what drive the file originated then when it gets transferred to LTO-6 tape via LTFS, we can quickly trace it in the event we needed to recreate the hard drive. Because tape archiving is linear, we can't store all of the files on the same tape.
    We've tried using Apple's Automator but it too seems to not have a way to batch change text in the Comments field. Any help is appreciated.

    What is "order data"?

  • Multiple Buttons in JTable Headers:  Listening for Mouse Clicks

    I am writing a table which has table headers that contain multiple buttons. For the header cells, I am using a custom cell renderer which extends JPanel. A JLabel and JButtons are added to the JPanel.
    Unfortunately, the buttons do not do anything. (Clicking in the area of a button doesn't appear to have any effect; the button doesn't appear to be pressed.)
    Looking through the archives, I read a suggestion that the way to solve this problem is to listen for mouse clicks on the table header and then determine whether the mouse clicks fall in the area of the button. However, I cannot seem to get coordinates for the button that match the coordinates I see for mouse clicks.
    The coordinates for mouse clicks seem to be relative to the top left corner of the table header (which would match the specification for mouse listeners). I haven't figured out how to get corresponding coordinates for the button. The coordinates returned by JButton.getBounds() seem to be relative to the top left corner of the panel. I hoped I could just add those to the coordinates for the panel to get coordinates relative to the table header, but JPanel.getBounds() gives me negative numbers for x and y (?!?). JPanel.getLocation() gives me the same negative numbers. When I tried JPanel.getLocationOnScreen(), I get an IllegalComponentStateException:
    Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
    Can someone tell me how to get coordinates for the button on the JTableHeader? Or is there an easier way to do this (some way to make the buttons actually work so I can just use an ActionListener like I normally would)?
    Here is relevant code:
    public class MyTableHeaderRenderer extends JPanel implements TableCellRenderer {
    public MyTableHeaderRenderer() {
      setOpaque(true);
      // ... set colors...
      setBorder(UIManager.getBorder("TableHeader.cellBorder"));
      setLayout(new FlowLayout(FlowLayout.LEADING));
      setAlignmentY(Component.CENTER_ALIGNMENT);
    public Component getTableCellRendererComponent(JTable table,
                                                     Object value,
                                                     boolean isSelected,
                                                     boolean hasFocus,
                                                     int row,
                                                     int column){
      if (table != null){
        removeAll();
        String valueString = (value == null) ? "" : value.toString();
        add(new JLabel(valueString));
        Insets zeroInsets = new Insets(0, 0, 0, 0);
        final JButton sortAscendingButton = new JButton("1");
        sortAscendingButton.setMargin(zeroInsets);
        table.getTableHeader().addMouseListener(new MouseAdapter(){
          public void mouseClicked(MouseEvent e) {
            Rectangle buttonBounds = sortAscendingButton.getBounds();
            Rectangle panelBounds = MyTableHeaderRenderer.this.getBounds();
            System.out.println(Revising based on (" + panelBounds.x + ", "
                               + panelBounds.y + ")...");
            buttonBounds.translate(panelBounds.x, panelBounds.y);
            if (buttonBounds.contains(e.getX(), e.getY())){  // The click was on this button.
              System.out.println("Calling sortAscending...");
              ((MyTableModel) table.getModel()).sortAscending(column);
            else{
              System.out.println("(" + e.getX() + ", " + e.getY() + ") is not within "
                                 + sortAscendingButton.getBounds() + " [ revised to " + buttonBounds + "].");
        sortAscendingButton.setEnabled(true);
        add(sortAscendingButton);
        JButton button2 = new JButton("2");
        button2.setMargin(zeroInsets);
        add(button2);
        //etc
      return this;
    }

    I found a solution to this: It's the getHeaderRect method in class JTableHeader.
    table.getTableHeader().addMouseListener(new MouseAdapter(){
      public void mouseClicked(MouseEvent e) {
        Rectangle panelBounds = table.getTableHeader().getHeaderRect(column);
        Rectangle buttonBounds = sortAscendingButton.getBounds();
        buttonBounds.translate(panelBounds.x, panelBounds.y);
        if (buttonBounds.contains(e.getX(), e.getY()) && processedEvents.add(e)){  // The click was on this button.
          ((MyTableModel) table.getModel()).sortAscending(column);
    });

Maybe you are looking for

  • Program won't start!

    Can anybody help me out? I just bought a new MacBook Pro, my first Mac ever. I had Final Cut Express pre-installed. When I went to open it up, it did the thing where it asks you what kind of camera you have. Well, I answered and told the program to i

  • How do I even restore it when it's died?

    When I connected my iPod to the computer today it doesn't show up either in My Computer or the Source List. There's been once a message popped out saying my iPod is corrupted and asked to restore. But the iPod now seems like it's died somehow - "Do n

  • Lumia 720 screen cracked

    Dear Nokia Support team, couple of questions on Nokia Lumia 720 - does the screen crack after falling from 3 ft given it is made out of gorilla glass? - can this be covered in the warranty? my device is just about 8 months old, and performing quite w

  • TS3554 i have lost my ipod touch , is there a way i can recover my photos and videos

    i have lost my ipod, and i am doing a  project at school and i need videos and picture, is there a way to recover them? urgent answer asap!!

  • Fade From B&W To Color With Full Color Text Animation Overlay

    So, this is my first time EVER  using any kind of serious video editing software.  I'm doing it LEGALLY using the University Macs and the software that is installed on it.  I'm a TOTAL novice at all of this.  I think I'm biting off on more than I can