Forcing a component to lose focus

Hi all!
How do you make sure that a component (such as a JButton) never gets keyboard focus?
If you're asking why I need this, I'm making a small program in which a button moves away from the cursor and I need to make sure that the user doesn't cheat by using the keyboard to press the button.
Thanks!

Never mind, I did it myself. For those interested, all I did was: JButton b = new JButton ("Catch me!");
b.setFocusable (false);Thanks anyway!

Similar Messages

  • Forcing a text component to lose focus

    I have several JTables and JTextFields in my GUI, and when I click somewhere off of any of them, I would like the one that has focus (if there is one) to lose its focus. The only way I know of to do this is to call transferFocus(), but if I do that, another text component will grab the focus, and I don't want that.
    One thing that seems to work is to disable the components when focus is transferred... then focus will not be grabbed. However, I don't want to leave these components in a constantly disabled state... then I would have to enable them again at the instant they are clicked on.
    Anyone have any suggestions?

    My requirement is that when empty space is clicked on, the component needs to lose focus. So it isn't like another text component is taking over the focus... I want nothing to be focused on.
    To better explain my situation, my GUI is a graph of nodes connected by lines. Each node has a few text fields and a JTable. When the user clicks on the background between the nodes, the node should be unselected and the focus should be removed.

  • Lose Focus

    Hello,
    I have a textfield that I want it to lose focus when the user hits enter key. I'm wondering if there is a way to just lose focus without having another component gain focus or setting setFocusable to false and/or setRequestFocusEnabled to false.
    vyang

    You can probably call setFocusable to false, but of course you usually would want to re-enable that at some point.
    But I'm not sure that there can be no focused component... except to declare all your components as non-focusable.
    Simplest is to just call requestFocus on something else or nextFocus or whatever.
    Very unusual for a text field, though. I don't know why you want to do this, but it seems not worth it, IMO.

  • I need to execute a formatted search when the field loses focus

    Is this even possible?  I do NOT want to force the users to press shift-f2 every time to validate/search on every field on the form.  This is absurd.  How can I trigger a formatted search on a field when it loses focus?
    I tried activating menu item #7425, but it's not executing the one on the field that loses focus, but a different one.  I guess it only works on the active field??
    I tried catching an earlier event, but after it executes the formatted search on the right field, it places the value on whatever field just gained focus instead of the one it was assigned to.
    Any ideas here?  We cannot force our users to press shift-f2 on all these fields!
    The only other idea I have is to not use a formatted search but instead try to create some sort of popup form with a grid and my own query.  There has to be an easier way, right?

    Bryan:
    I use the following on a KeyDown event for when the User tabs out of a field after entering data if the data they entered is not valid.  Perhaps you could try this in the LostFocus event:
    g_B1Connection.Application.SendKeys("+")
    Also, I have used this in the KeyDown event:
    DisplayLookup("txtWO0")
    Private Sub DisplayLookup(ByVal objText As String)
            Try
                WOItem = WOForm.Items.Item(objText)
                WOItem.Click(SAPbouiCOM.BoCellClickType.ct_Regular)
                g_B1Connection.Application.SendKeys("+")
            Catch ex As Exception
                g_B1Connection.Application.MessageBox(ex.Message, "Ok", 1)
            End Try
        End Sub
    Thanks,
    EJD

  • While Printing using Print Button on Crysal Report Loses focus.

    Hi all,
    I am using CR XI along with VS2003 for developing my application.
    My application uses a Treeview to list all the available reports, once user select one of the report. I am using another dll, which contain all the rpt files as Embedded Resource, for showing the report in Crystal report viewer.
    Once report get loaded, I am using Print Button from Crystal report viewer to print the report.
    report get printed properly..
    However a strange behavior occurring, Form with Crystal report viewer control placed loses focus and immediate below window coming into focus (some other opened window get activated and bring to front and hiding my application).
    Any suggestion would be appreciated.
    Thank you
    Riju K K

    Hi Brian,
    Thanks for you are reply.
    I think I am not creating a separate process,
    From my application, I am creating an instance of form (which is in another DLL) which is hosting Crystal report viewer.
    If click "Print" button on the Crystal report viewer, I am getting a Printer selection form.
    If I cancel from there ,my Crystal report viewer form get focus back.
    If select a printer and click "OK". my Crystal report viewer form lost focus and some of the other window opened (word, ie, etc) before get focus.
    My assumption is Crystal Report viewer's "Print" button may be using a separate thread for Printing.
    that may creating this focus issue.
    what you think?

  • Firefox 3.6.8 does not recognize subsequent mouseclicks - window loses focus

    After updating to firefox 3.6.8 on my macbook pro (OS X 10.4.11) Firefox fails to recognize subsequent mouse clicks. You can access the page initially, but then it seems to lose focus and become unresponsive to mouse clicks until you do something to break the cycle (clicking on desktop, minimizing and resizing window, etc). I reinstalled Adobe Flash update using full installer, since others have suggested that as a possible cause, but no joy. The browser window still does not recognize mouseclicks after an initially successful page load. You can tab to the next window (for example, if you want to enter something in search) but you cannot CLICK to enter the search window, nor can you click on links on the page, etc. It is totally unresponsive.
    == This happened ==
    Every time Firefox opened
    == I updated Firefox to the version just before 3.6.8 -- then I updated to 3.6.8 to see if that fixed it -- it's still broken

    This started happening to me yesterday. All plugins are disabled, didn't help. All plugins uninstalled, didn't help. Downgraded to SP3, didn't help. I've also noticed this happen in Thunderbird, though it seems OK now.
    Sadly I've had to start using IE8 :(

  • Using web.show_document the first time makes new browser window lose focus

    Hi,
    In our application we use show_document(url, '_blank') to open our reports (as pdf) in a new window.
    Our environment is Application Server 10g Release 2 with Forms 10g Release 2 and jinitiator 1.3.1.22.
    The first time I call a report, the new browser window containing the pdf is shown but loses focus after about 1 second. The focus is then returned to the applet window. When calling a report again it always keeps the focus.
    After closing the applet window and restarting the application, the same thing happens: first report called loses focus, all others keep the focus.
    Does anyone have any idea why this is happening? We want the focus to stay on the new browser window every time...

    Hi Jeroen,
    I m also facing a problem something similar to yours. If you got any solution please let me know.
    Problem-
    Currently my application is running on Forms 9.0.4.2 and my form calls another third party which displays the image in image viewer in new browser. When user clicks on the button to display image, then I m using the following Code -
    -- Method: displayDocuments ([Ljava/lang/String;)Ljava/lang/String;
    FUNCTION displayDocuments(
    obj ORA_JAVA.JOBJECT,
    a0 ORA_JAVA.JARRAY) RETURN VARCHAR2 IS
    BEGIN
    args := JNI.CREATE_ARG_LIST(1);
    JNI.ADD_OBJECT_ARG(args, a0, '[Ljava/lang/String;');
    RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'com/hli/imaging/adapter/LK_FormsImagingAdapter', 'displayDocuments', '([Ljava/lang/String;)Ljava/lang/String;', args);
    END;
    Image is displaying fine but the focus is staying on the newly opened browser. I want it to get back the focus to the forms window.Is this possible ???
    Thanks in advance
    Sai                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I use photoshop elements 12 on Macbook air and the screen freezes when I try to use the tools. Then i have to force quit so i lose my work. anyone know how to fix this issue?

    I use photoshop elements 12 on Macbook air and the screen freezes when I try to use the tools. Then i have to force quit so i lose my work. anyone know how to fix this issue?

    What version of OS X are you using? If Yosemite, you need to update to 10.10.1 or higher.
    In any case, start by going to the editor preferences>general, clicking this button and restarting the editor:

  • Aperture loses focus, even in other programs

    I developed a new problem over the past week or so. I'll be typing along in any program when it suddenly loses focus. I can click to re-establish but, once it starts. it happens every 10-15 seconds. I think I've isolated the issue to Aperture. Once I quit Aperture, the problem seems to stop. When I'm using Aperture, it's begun acting strangely: multiple clicks required to select photos, shift-click to get a range doesn't always work, right-click menus pop up then disappear or don't contain all items expected (e.g., Export only shows "Project as new library" as a sub).
    I'm up to date on Yosemite (10.10.1) and Aperture (3.6 500021000000000.3 RAW 6.02/Build 768.6), and I'm struggling to key the start of this phenomenon to any particular update (assuming Aperture is winding down and Photos will come soon?) I haven't tried to reinstall Aperture, although I did have a repair situation a couple of weeks ago when I had a white screen of death in OS X.
    Has anyone experienced this? Any suggestions beyond repair/rebuild? I've been exporting originals for a while with the expectation of changes ahead and will continue with that as best I can...

    So, I had some time (and accumulated frustration) to check on this further, with no positive results.
    I thought I might need to repair or rebuild my Aperture database. I tried following the instructions in the Help file (Control-Command-Click on Aperture database in Finder) but that did not yield the dialog to repair/rebuild, just launched Aperture.
    I used Activity Monitor to try to see what was running, and I seem to get a process called "ReportCrash" that cycles into the CPU use column every time the focus changes. But, I haven't gotten the typical "Program has crashed. Do you want to send a report?" dialog. It happens every 3-10 seconds, and only happens when Aperture is open. I haven't tried reinstalling Aperture yet because I haven't had a chance to dig out installation disk stuff.
    I may try to cross-post this to a Yosemite forum to see if it's just coincidence that it happens when Aperture is running.
    Maybe it's just life telling me to ante up for LightRoom...

  • Lose focus when tabbing out of autoSubmit text box in IE

    Hey,
    Using JDEV 11.1.1.4 I have a problem with tabbing from one textbox to another textbox in IE. Both text boxes have autoSubmit=true and to reproduce the problem it's like so:
    I type a value or edit the existing one into text box 1 and press Tab. The submit is done and focus is given to the second text box but only momentarily before it loses focus. The focus then is given to the window it would appear, because if I press Tab again it begins from the top of the page. This is only happening in IE (v8 is all I have tried so far). This ONLY happens when the value of the second box is null. If it has a value all works fine.
    I tried implementing various solutions including using the ExtendedRenderKitService to write javascript to the client from the bean to set focus on the text box after the partial render. The javascript is called and focus is set but then something else calls blur on it afterwards. I have verified this by putting a blur event listener on it and it gets called after I set focus on it from my own javascript!
    Has anyone experienced something similar? Just to note: It only happens in IE, and it only happens when the second text box is empty.
    Thanks,
    Ross

    Hey John,
    In reply to your message
    1). Tried on 11.1.1.6 to see if the issue is still there?Not really an option to try and upgrade and test if it works there.
    2). Made a simple test case removing as many variables as possible (e.g. do a simple screen with no DB interaction and only two fields) to see if it reproduces or it's something with your screen?Tried this an it works fine which means it is something unique to my code.
    3). Filed an SR at https://support.oracle.com with your test case
    As above it looks like it's not a problem with ADF so I will keep looking at it.

  • Word 2011 for Mac Book pro - I have found that my cursor disappears sometimes when I click on a toolbar function. I found out it is a bug, that the Mac loses 'focus'. I can correct it temporarily by clicking on Format - Font - Cancel. Any info?

    I have Word 2011 on a Mac Book Pro and have had problems with a dissapearing cursor - it makes editing tricky
    After googling it I found out that there is a bug where the Mac loses focus if you click away from the document - it also does this with italics according to other users.
    I had a play with it and found out that when I click on the toolbar in a document where this happens, the cursor disappears, e.g. changing font colour etc. And then, when I click on Format - Font - Cancel it returns
    I'd be interested if anyone else has a comment to add, please do
    thanks

    BTW (speaking as a Dad of 3 daughters in Grad school) if you don't already have and use a DropBox account, or some other similar online "cloud" based backup of your school documents, you should start doing so immediately. By keeping all of your important documents in the Dropbox folder on your computer, you have instant access to them from any other computer (or iPad), should you be w/o your computer while in for repairs (or if, God forbid, it is stolen). It's free for 2 GB of online storage, which is more than enough for a few years worth of Word documents, etc. (If you get other people to sign up via your email "invitation", then Dropbox gives you even more free storage space.) Every time you close a document, it is updated on the Dropbox servers (encrypted), if it is in the Dropbox folder (assuming you give it a few seconds to update before turning off your computer). Do a google search of "Cloud based storage comparisons" to compare the amount of free space each of the competing services give you.

  • JS CS3: ScriptUI - window and panel loses focus on Mac

    Hi,
    Have made a script to export selected textframes as text files.
    When the script runs on a PC the script window stays in front of the document as intended.
    Much to my surprise this is not the case on Mac, On Mac the script loses focus and goes behind the document.
    Is this a bug or is there a workaround?
    Using the folowing to create/start the UI.
    var win = new Window( "window", "Text Exporter" );
    win.myPanel = win.add("panel");
    with(win){
        win.Pnl = add('panel', undefined, 'Textframes for export');
        win.Pnl.orientation = 'column';

    Something is wrong.
    That's not the behavior that I see using palettes.
    The only way I can get a palette to become inactive is by switching to 
    a different document window. Even when it becomes inactive (greyed 
    out), it does not require extra clicks...
    If you want to activate it programatically, it's win.active = true.
    Harbs

  • Is there a way to keep the ADL open when testing CS5.5 Air apps after it loses focus?

    When I test Air applications (specifically targeting mobile) it seems that when the ADL (Air Debug Launcher) launches, it will automatically terminate the session when I click on anything else other than the ADL window.  I have been trying to use 3rd party application debuggers that provide improved memory diagnostics, but these debuggers only seem to be able to work when the application is launched through the Flash Player and not through the ADL.  Unfortunately, the Air specific code will only work in the ADL.  Is there some way to keep the ADL running even when it loses focus?  I have tried using the ADL from the Flash CS5.5 IDE as well as from the command line and both will terminate upon losing focus.

    - Transfer the app to the computer by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    - Connect the iPod to the computer and make a backup by right-clicking on the iPod under Devices in iTunes and selecting Back Up.
    - Restore the iPod from that backup. That should also update the iPod.

  • Second window loses focus

    Hi all,
    I set up a navigation between two wd applications within the portal. The navigation will open a new window once the user clicks a button in the first application. The navigation itself works well, however, the new window is always shown behind the portal page, in other words, it loses focus after it is opened.
    Does anyone know a way to bring the new window to the front?
    Thanks!
    Hart

    hello thomas!
    is this problem with the losing focus when you open a second window fixed now?
    can i set the focus in a new opening window manually?
    thanks for your help...
    peter

  • When does a selection in a text field in a Finder window lose focus?

    Hello,
    this problem has emerged on account of an Applescript file that needs to access a text selection (portion of a filename highlighted) in an open Finder window.
    The bare minimum code to demonstrate the problem is this:
    *tell application "System Events"*
    * *tell process "Finder"*
    * *set selText to value of attribute "AXSelectedText" of text field 1*
    * *end tell*
    *end tell*
    other variants also exist, using "keystroke" but that does not work either. I am not asking help with Applescript here, it is here only to give a sense of the problem.
    My conclusion thus far is that the selection lose focus before the script process can access it. In the best case I get the full filename by using "attribute" and copy of the alias onto the clipboard by using "keystroke".
    So my problem is this:
    It seems that the focus stays alive when one clicks on a menubar item, any click on any other item on the desktop, including windows of irrelevant applications, changes the focus from the selection within the text field corresponding to a filename, to the filename itself.
    And my question is this:
    Is there a changeable setting within the OS that has to do with how long the focus stays alive on a selection within a text field corresponding to a filename? If yes, how do I change it?
    Thanks

    baltwo wrote:
    Thanks for clarifying. Never heard it called a text field, just a label. So, exactly what are you trying to accomplish? Is it that you want AS to select the file, highlight its label so you can edit/change it with some other text? If so, have you checked out the Finder scripts installed on the machine, especially the Finder script *Add to Finder Names*?
    UI Element Inspector calls the activated/editable filename a text field.
    Actually I want to modify one of the stock Finder scripts. I want to be able to select part of the file name in the active text field of the Finder window, then activate the script, *have the script pick up the selection* as a text string then use it internally.
    The bolded step is the one in question.
    Every attempt fails on the fact that the focus is lost from the "text field" and it reverts to the label for the filename, if I may use this distinction, (or to "FinderItem" in the parlance of UIEI) as soon as another process begins, it seems. So when the script becomes active, but before any of the commands is executed, the selection disappears.
    My guess is that it is not some absolute necessity but a setting that perhaps can be changed somehow.

Maybe you are looking for

  • While downloading file to application server its overwriting the earlier fi

    hi if i am using below code with date time stamp the file is downloaded to the application server correctly and each time i execut eht program a difference file is generated as date time stamp differs each time but whne i remove the date time stamp i

  • Installing proofing tools without installing whole operating system?

    Hello! I have discovered that the English proofing tools are not installed as part of Microsoft Office. Can I install them from the Install Discs or do I need to uninstall the whole operating system (OSX 10.5.5) and install from scratch? Thanks for a

  • Help regarding pop up

    hi, i would like to know the various ways i can use a pop up to edit a certain field in an alv display and the change gets reflected in the display

  • Java error in Oracle Help Demo

    Hi, I'm trying to get the Oracle help demo to work on a weblogic server (version 10.2.3) but I get a Java error when when I attempt to navigate to the test page at http://server:port/ohw-rcf-demo I've checked the dependencies for the thin demo and th

  • UCM-BPEL Integration

    Hi, we're trying to integrate UCM with BPEL. I've added the component BpelIntegration_10gR3_20071213.zip to the content server without any problem. My doubt is how to configure the connection to BPEL. We are using Weblogic and all the documentation t