How to keep focus on button while entering text

Hello,
In a JFrame I have a JButton and a JTextField
I want it so the user can enter text in the field and hit 'Enter' to trigger the ButtonActionPerformed event.
I figured, once a JTextField event like keytyped happens, I could button.requestFocusInWindow();
But then I cant type into the TextField anymore.
How is this done?

Use this:
getRootPane().setDefaultButton(yourButton);
This will make your button the default button if you are using a JDialog or JFrame. When the user finishes typing and presses enter the button will respond.
I think this should work in a JFrame as well. I used it in a JDialog.

Similar Messages

  • How to keep the save-button active all the time?

    Hi!
    I'm using mobile sales 4.0.
    On a tile i've only fixed questions and combo boxes with yes and no ...
    When i write manually a "yes" in the combo box field the save button is active - When i use the combo box with a mouse click the save-button isn't active.
    What are the settings i've to do to keep the save-button active all the time?
    Thanks a lot in advance.
    Best regards,
    Ingo

    Hi Ingo,
    If your combobox is a bound control, then when you change a value in it, the save button should be enabled. Strange. But anyway, you can do this.
    In the <b>combobox_OnValueChanged2</b> event, make a call to makeDirty method in the tile:
    If boundAttributeChanged Then
         <b>anchorthatyourcombotiedto</b>.bo.MakeDirty True
    End If
    This will make the Save button enabled.
    Regards, Vadim.

  • How to keep file sharing on while MacBook lid closed?

    would like to keep file sharing on while lide closed on macbook...so i can access files with other device.

    i really dont want to be needing to buy a extra screen just to get something working that i had going before...
    i do have a bluetooth mouse attached and everytime i move it..the macBook seems to start up but then immediatly goes back to sleep..playing dead
    all i want is that file sharing continues when i close the lid...
    Do you think that it might be a hardware problem?
    Or maybe software...because since I downloaded Lion...screensaver has been jumping in randomly too...I know it's nothing special since many people have encountered this issue and i just reinstalled lion and it seems to be fine so far....
    anyhow... still hoping to find the right solution...
    But thanks for the help..really appreciate it...

  • Using numberd buttons to enter text into a field

    Hi all, was wondering if I had 10 seperate sprites acting as
    buttons on a page, which will be numbered 0 -9, is it possible to
    use them to enter text into a field. e.g.
    If the user presses the sprite with a number 1 on it, would
    it be possible to have a 1 displayed in an edit field. I need to
    pretend as though im using a remote.
    thanks

    You can create a behavior that will allow you to set a
    variable for each
    button. When you assign the behavior to your button sprite,
    it'll
    prompt you to enter the ButtonNumber property. Haven't tested
    this yet,
    but something like this should work:
    global gNumberEntered
    property ButtonNumber
    on getPropertyDescriptionList
    description = [:]
    addprop description, #ButtonNumber, [#comment:"Enter number
    to assign
    to this button", #format:#integer, #range:[1,10], #default:
    1]
    return description
    end getPropertyDescriptionList
    on mouseup
    sprite(the currentSpriteNum).member = member("buttonOver")
    gNumberEntered = ButtonNumber
    cursor -1
    end
    on mouseEnter me
    sprite(the currentSpriteNum).member = member("buttonOver")
    cursor 280
    end
    on mouseDown me
    sprite(the currentSpriteNum).member = member("buttonDown")
    end
    on mouseLeave me
    sprite(the currentSpriteNum).member = member("buttonUp")
    cursor -1
    end

  • How to set Focus on button?

    I would like to hit enter key after the user id and password. The focus should be set on the OK button. But when I hit the enter on the keyboard and it doesn't work. Hope anyone who knows this can provide some helps in way. Thanks in advance.

    Tom is right, but if your button doesn't lie directly on a "contentPane" , the getRootPane method return a null value.
    The other way to set the focus on your button is to call
    button.requestFocus() method ,
    but be careful :call it after you call setVisible(true) (or at least after you call pack()) on your frame or dialog (I suppose you have one) .
    A Swing component that's a top-level window is realized by having one of these methods invoked on it: setVisible(true), or (this might surprise you) pack(). After (just after!!) a window is realized, all components that it contains are realized (you could think they now exist).
    It is useless to call reqestFocus() before setVisible(true) or pack() .
    Hope it helps!
    Paul.

  • Yikes! Moving tomorrow, don't know how to keep hi-speed int. while 'homeles

    Hi - sorry to post this if these are redundant or foolish or otherwise lame questions!
    How do I maintain hi-speed internet access for my PowerBook G4 while I am travellling and betwenn permanent addresses?
    I have had cable or DSL through a cable service or home-phone service so long that I just realised I have no clue what to do for my short-term dilemma.
    I'm turning to this board because my conundrum involve various providers, I don't know what I should cancel, change or what!
    Nor do I expect to get straight information out of said providers.
    I'll try not to 'name names" on the providers to keep feelings out.
    Here's my scene:
    We are moving out of state - today.
    We won't have a permanent address until January 05, 2007
    Our present set-up is:
    Cable internet access and Cable TV through my Cable Provider.
    Internet account is an ISP that goes through my local cable provider.
    Phone service is a Voip that connects through my Internet access.
    My email address is a .mac so I know that's that's ok.
    Significant Other refuses to give up his email address as he's had it forever.
    That adress is .ourcurrentISP.com
    Other Issues:
    Our ISP is really a drag to deal with, takes hours to get often useless or wrong info.
    I don't have a contract with them now so cancellation fees are not an issue.
    I would prefer to limit our involvment to bare minimum; just for the email address, if possible.
    OUr local cable can probably suspend or move our account to wherever we are moving but that is still a few weeks away.
    The Voip has been easy to deal with so I suppose that isn't too much of a hassle to figure out.
    SO: How do I get high-speed internet access for my Powerbook G4.
    PS: I'm pretty lingo-illiterate, especially when moving cross-country during busy holiday week. heh.
    Thank you thank you.

    Check http://www.jiwire.com/ for a listing of hotspots in your area. It also lets you search for hotspots which are free.
    Note your outgoing mail server is going to be the tricky part to immitate at hotspots, as many block this unless you use password authentication with your old e-mail server over port 587 or 2626. However, you can use webmail setups such as http://www.3wmail.com/ and http://www.mail2web.com/ if you need access to e-mail during that period.
    Also some of the free hotspots require using Firefox to establish a connection with their wireless router. Using Safari will get you a server not found until that connection is established. Such is the case with Panera Bread's free wireless access in Silver Spring, Maryland. Firefox is a browser you can download from http://www.mozilla.org/

  • How to keep default radio button ?

    Hello,
    I am having created 2 radiobuttons in my screen where i have went to edit in the menu bar and Radiobuttons define.
    But when i am saving the radiobutton text it is saving only when i click the radiobutton even defaultly present radiobutton also if i am clicking then only it is saving.
    My requirement is like the defaultly present radiobutton should save.
    Thks

    Hello Reddy Garu,
    My probelm id i have declared by two radio buttons as in
    Top Declarations as
    DATA: RADIOBUTTON1 type c,
              RADIOBUTTON2 type c,
              RADIO TYPE C.
    PAI
    CASE SY-UCOMM.
    when 'LIST1'.
    if radiobutton1 = 'X'.
    WA_CLPI-RADIO = '1'.
    WA_CLPI-OK1 = 'OK'.
    elseif radiobutton2 = 'X'.
    WA_CLPI-radio = '2'.
    WA_CLPI-OK1 = 'NOT OK'.
    ENDIF.
    I declared like this since my code is working fine while saving the records of radiobutton texts.
    But when i am trying to implement your code...
    Data: RADIOBUTTON1 as radioButton group gp1 default 'X',
             RADIOBUTTON2 as raioobutton group gp1.
    Then it is displaying a error message as AS is not defined.
    Please help me eith the answer.
    Thks

  • How to keep data in session while changing webshop in ISA 4.0?

    Hi All,
    I have one requirement in my current project. We are showing Webshops in "categoriesB2C.jsp" file in "left" side. We have four webshop as below.
    1) Shop By Market
    2) Shop By Product
    3) Shop By Quick Ship
    4) Shop By Price.
    I am hiding webshop in "Categories.jsp" selected in "shoplist.jsp" now when I put some product in shopping cart or I login in B2C. and then click on any link of webshop which I have provided in "categoriesB2C.jsp" I am using below link
    "<a href="/b2b_virco/b2b/init.do?shopId=PRODUCT">" around webshop name in "categoriesB2C.jsp" if I use
    <a href="/b2b_virco/b2b/readshop.do?shopId=PRODUCT"> then I am getting error.
    Now I want to preserve my selection while changing the webshop.  right now it is changing the webshop but it is not preserving the data in "cart" and if I am login then it just throw me out and reset my selection in shopping cart.
    Any idea or any help is a great help for me.
    Thanks.
    Ashish Patel.

    Dr. Iman, thanks, but I made your suggested change and the same result applies. I removed the "Close File" vi from the loop and even wired a "False" boolean variable to the "Close When" port of the "Write to C" vi. The results from previous loops are still being over-written by later loops leaving only one loop of data by the time the vi is finished running.
    Any other ideas? I have attached the latest version of the vi that I am working on this.
    Attachments:
    Traverse_Alive_Triple_Bypass.vi ‏140 KB

  • How to keep anchor in middle while changing height and width for comp in extendscript?

    When i try to change my composition height and width using extendScript, it works but with anchor point at top left corner. How do I maintain it at the center??
    My code:
    comp.width = 4000;
    comp.height= 4000;
    result:
    expected:
    Thank you

    So you caught me on an open day, and I even dragged in another staffer (Josh) to sit and figure this out and we did. I just need to clean it up into a function for ease of use. It literally became an obsession between Josh and I to figure this problem out. We seriously need to get outside more, haha. I'll post the solution here shortly once it's cleaned.
    Is there a way to access layer's properties like position, rotation etc without its comp open or selected and not knowing its item number.
    Finding layers can be done by looping through all comps and all layers. You must set a series of matching criteria to compare against so you don't accidentally grab a duplicate layer that has the same values though. Usually the layer name, size or any property spec that is unique, source asset if it's an AVLayer, etc... It's also possible to have a list returned that you choose from if you wanna verify the layer before proceeding. All this has to be manually coded though.
    var comp = app.project.activeItem;
    var layer = comp.selectedLayers[0];
    //assuming layer is a comp
    layer.duplicate();
    var num = layer.index;
    var name = (layer.name + "_comp");
    var newComp=  comp .layers.precompose([Lnum], Lname, true);
    newComp.width =  4000;
    newComp.height =  4000;
    now what am trying to achieve is move the comp (layer) to the center of newComp i.e at 2000, 2000
    I'm not fully understanding the process you are intending. You are searching for precomps (comps used as layers) basically?

  • How to make "Terms & Conditions" button while activating your iPhone works?

    When i was activating my new iPhone 3G with iTunes 10.5, i was shocked that when i press the continue button in the "Terms & Conditions" page nothing happens, and it doesn't continue to the next page.
    Please help i can't use my iPhone doing anything.

    I have this problem too. Have you figured it out? I'm so frustrated and I tried to call Apple but it would cost $35 to get the question answered. I am hoping someone here can help.

  • How to keep iMac screen black while keeping secondary monitor running for visual experiments in Matlab

    Hi,
    I'm trying to run a visual experiment using PsychToolbox in Matlab.
    I've attached a secondary monitor to my iMac for this purpose and I'm having difficulties trying to
    'black out' the iMac screen.
    I need the secondary monitor to run at a refresh rate of 120Hz and at linearised luminance (did this for my secondary monitor),
    so I can't really use my iMac screen. However, i need my iMac screen to be darken out because I'm doing a vision experiment.
    I tried dimming my iMac screen but it doesn't go completely dark. I tried Ctrl+Shift+Eject (or was it Command) but it will darken both
    monitors. I also tried mirroring, but it doesn't seem to work too.
    I'm really stuck and any ideas will be greatly appreciated!
    shui
    NB:I'm using OS X Version 10.8.3.

    I do not know the details of your experiment, but creating a black monitor is not difficult. For example a completely black page, e.g. in Power Point, set to fill the screen?
    The advantage of doing this with PP is that you can move in to or out of the black page with just the space bar. You can set up your monitors so PP is displayed on just one monitor.

  • How to keep Canon 5dMk2 "connected" while shooting tethered

    Folks,
    Is there a trick?
    When I shoot tetherered LR3 loses contact with my camera (5Dmk2, but also 30D) way too quickly before shooting an image. Just fiddling with the props, set, lights, etc., is enough to lose contact. I have been turning the camera off and then back on but that's ridiculous.  I want just leave that rig set to make me a full screen image upon testing (firing shutter) and holding that image as long as I need foe extended checking. When I set it for live view on the tethered laptop I want it to stay open, as I probably have the laptop plugged in.
    What am I missing here in the way of a setting?
    jonathan7007

    First, a caveat...  I don't use tethered shooting much.  Infact, it's been at least a year, but my last experience...
    You generally lose connection when the camera auto-shuts off.  So if you set the camera to not do that (external power? Menu setting?) then you shouldn't lose connection.  But I don't remember if it's possible for that camera to be set to not auto shut off.. if not, set it for as long as you can.  At least, that's what I remember!  Sorry if I'm not more helpful!
    Cheers!

  • I am losing my carriage returns when sending emails. How to keep? uses SMTP Email MIME Text Content-Type.vi

    I am losing my carriage returns when sending emails using the Internet email vi's.
    All carriage returns are stripped out and I get one long word wrapped paragraph.
    I want to avoid html.
    Ideally, using the vi's for rich text would be perfect, but a simple text message with carriage returns and line feeds in any font ok. 
    uses SMTP Email MIME Text Content-Type.vi
    i have tried text/plain, text/html, and mixed yada something

    You need to use Line feed constant and then use concatenate function.See the screen shot.
    Naqqash
    Attachments:
    Using Line feed.png ‏15 KB

  • Entering text in safari

    In safari browser, while entering text in controls, the texts are getting doubled.(i.e if i enter "2", it's displayed as "22" and "s" means "ss"),
    How to overcome this?
    This happens only for safara, others browsers its working fine.

    Tim, what Extensions have you added on to Safari? 

  • Linking a radio button to a text field in a pdf form

    Forgive my ignorance but does anyone know how to link a radio button to a text field in an Acobat pdf form?
    I have a series of 4 radio buttons. If you click on one of them I would like to activate a text field which you then have to fill in. In addition it would be good to have it so that if you don't click on the radio button you're not able to fill in the associated text box.
    I am a designer not a programmer so I don't know much about javascript. Can anyone help?
    Many thanks

    You might want to look at Hiding and Showing Form Fields by Thom Parker. You might also want to clear the text field when the radio button changes.

Maybe you are looking for

  • New install after hard drive loss - no backup available - what to do?

    Hi, Recently lost my iTunes library due to harddrive failure. Unfortunately I do not have any backup of my library at all. Will I lose all my content from my iPodTouch if I synchronise with a blank iTunes library? Any help would be much appreciated,

  • BSEG - Select statement slow

    Good day master's! I'm having a so slow query with this code: SELECT EBELN BELNR AUGBL GJAHR KOSTL INTO TABLE IT_BSEG FROM BSEG WHERE EBELN EQ LS_EKKO-EBELN AND BUKRS EQ S_BUKRS. I use ABAP debugger and found out the cause why my program are so slow.

  • XML message is not processed in SXMB_MONI

    In SXMB_MONI txn code (PI 7.0),we are not able to get updated with any XML messages from a folder on application server what could be a reason for this problem..can we see the log details of the same from anywhere .How can we rectify this problem I w

  • Change Name option in 5.3 CUP

    I am configuring a new 5.3 CUP and wonder if anyone is using the 'Change Name' request option. And if so how does it work? I tried to use it but it only asks for the old ID and I am not sure what it will even do.

  • Export Address Book Features

    I'm trying to simplify managing Address Book contacts for exporting to an e-mail marketing application (Campaign Monitor). The problem is that when a contact has multiple e-mail addresses they will be displayed as a separate column in a CSV file but