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.

Similar Messages

  • 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!

  • 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.

  • 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.

  • 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.

  • 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

  • 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

  • TextInput loses focus after a collection.refresh()

    Hi!
    I have TextInputs inside AdvancedDataGridHeaderRenderers in my ADG making filters by columns.
    But everytime I press a key (and collection.refresh() is called) to make the filter, the target text input loses focus after the call to the collection.refresh() method.
    The ADG headers inputs have the same focusManager object of my parent IFocusManagerContainer, but they are inacessible by TAB (and they do not TAB to each other).
    A note: My collection.refresh() method is called from inside my ADG override of commitProperties method.
    Any ideas?
    Thanks!

    I'd first make sure you need to make a change that requires a refresh.
    There are various ways to avoid/block refresh. It will depend on your needs.
    There is an API on ICollectionView, there is making certain properties not
    bindable and there is capturing and stopImmediatePropagation on the change
    events themselves.

  • TextField loses focus only to another TextField

    ...when any UIComponent is onstage. If a UIComponent is not onstage, I can click anything else, even the blank stage backing, and the TextField loses focus.
    I want the TextField to have a FOCUS_OUT event when the stage (or anything else) is clicked. How can this work when there are a number of UIComponents onstage? I can hack it by putting a blank text field in back of everything, but that won't work in every case. Any ideas? Thanks.

    textField2.setDocument(textField1.getDocument());Once you do this, whatever is put into one text field will show up in the other and vice versa. Not sure if this is what the OP wants, but it does solve the problem.

  • Password dialog box loses focus

    I know this happens on my iMac Lion 10.7.4.  I think I saw this recently on my MBA with MtLn.  I do something that requires admin priviledges such as start a program install and a login dialog box pops up as it always has so I can log in as an administrator for the higher privilege.  If I don't immediately start typing the password (wait even a few seconds) and the focus is lost by the dialog box.  If I do a keystroke, I get a sound you hear if the keystroke has no place to go  -- the focus has not been set to any window receptive to keystrokes.
    However, if I beat that time out, or more usually, click the mouse on the text entry field and immediately type the first character of the password, it isregistered with the dot echo and the focus remains on that field while I enter the rest of the password.  The only pointing devices attached to my system are the Apple Magic mouse and Apple Magic trackpad.  Both are attached by Bluetooth. 
    Any ideas?

    This was happening to my parents' computer too.  Each time the admin password was required, the dialogue box would lose focus in less than a second.  You had to time your keystrokes very quickly.
    I reviewed in Console what was running and found that their dictation software (Dragon Naturaly Speaking Express) was the culprit.  When I turned it off, the problem never returned.  So perhaps it's along the same lines for you: that some service such as dictation software is causing this issue
    Run your console log and place yourself in the very situation where it would normally occur and see what comes up in the logs.  For me it was com.dragon.express.
    Oh, and to let you know, they, too, have a mighty mouse connected by USB and a magic mouse (by Bluetooth) and these were not the problem.
    Good luck! and Happy Holidays

  • How to email text from a text component in my applet on a the host server ?

    How to email text from a text component in my applet on a the host server, back to my email address ?
    Assuming I have Email Form on the host server.
    Help will be appreciated.

    You can do like below
    =REPLACE(Fields!Column.Value," " & Parameters!ParameterName.value & " ","<b>" & Parameters!ParameterName.value & "</b>")
    The select the expression and  right click and choose placeholder properties
    Inside that set Markup type as HTML 
    then it will highlight the passed parameter value in bold within the full xml string
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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...

Maybe you are looking for

  • How to include .class or xml file in a JNLP

    Hi, I want to include an xml file in the JNLP file. Can any one tell me the syntax to include it plzzzzz..... Regards, Prasanna

  • Sort pictures in a new Gallery

    Hi I have creatded a picture gallery with 50-60 pictures in it. I draged and dropped the pictures into the gallery and all the pictures landed in a mess..... not in number order??? Why? How can I sort them in number order? // BR / J

  • How to move data from one cell/sheet to another

    Hi - Help! I have a spreadsheet with multiple columns & rows for ordering clothes. The first column is  text of each item & it's size. What I want to do is: IF D15 has a number in it, I want that number and the text from A15 to populate into another

  • CPU Usage Spikes

    My computer was not responding well when I tried to install a driver for my webcam. The error message said that I should try uninstalling some recently installed programs. So I did. There were some that were recently installed but I didn't really kno

  • Many unrecognized certificates in System Roots, delete is grayed out

    I have many unrecognized certificates in my System Roots area and in Certificates. I searched the web to see how to delete them. The 'delete' option under 'File' is grayed out. Is there something I'm missing? Many of these certificates have slightly