Focus in text box

Hi,
I am writing a login dialog which has two text fields, one for username and other for the password. I want the focus on username field when the dialog is displayed. I have tried two approaches:
I) I added the focus listner to the dialog and passed the focus to the username field at the time of initialisation
II) I added the focus to the username field by:
a) username.requestFocus();
b) username.requestFocusInWindow();
I am testing my code with JRE1.5 on Solaris and HPUnix. The behaviour of the code is not consistent. At times I can see the cursor blinking in the username field but sometimes there is no focus.
Is there anything wrong in the above approach. Or can anyone suggest a better way to do this?
thank you.

public JPanel createLogInPanel()
JPanel loginPanel = new JPanel(new VerticalLayout(10, 10, 10, 10, 10));
JPanel dataPanel = new JPanel(new
PropertyLayout(10, 10, 10, 10, 10, 10));
JPanel buttonPanel = new JPanel(new
ButtonLayout(ButtonLayout.HORIZONTAL,
ButtonLayout.CENTER,
ButtonLayout.DEFAULTGAP));
userNameTxt = new JTextField(10);
passwordTxt = new JPasswordField(10);
final JButton logInButton = new JButton("Log-In");
JButton clearButton = new JButton("Clear");
JButton cancelButton = new JButton("Cancel");
dataPanel.add("1.1.bind.nobind.center.center", userNameLabel);
dataPanel.add("1.2.bind.nobind.center.center", userNameTxt);
dataPanel.add("2.1.bind.nobind.center.center", passwordLabel);
dataPanel.add("2.2.bind.nobind.center.center", passwordTxt);
buttonPanel.add(logInButton);
buttonPanel.add(clearButton);
buttonPanel.add(cancelButton);
messagePanel.add("bind.nobind.center.center", errorMsgLabel);
loginPanel.add("bind.nobind.center.center", dataPanel);
loginPanel.add("bind.nobind.center.center", buttonPanel);
loginPanel.add("bind.nobind.center.center", messagePanel);
userNameTxt.requestFocus();
return loginPanel;
This is what I am doing. Where is the change needed for the Z-order?

Similar Messages

  • How do I stop Firefox from auto-focusing on text boxes?

    How do I stop Firefox from auto-focusing on text boxes? Sometimes as a page is loading, I scroll down the page...only to have the page jump back to where there is a text box, with a blinking cursor, after the page is finished loading. It is an annoying feature and I want to turn it off.

    Some pages use an onload event to set the focus to a text area or search field.
    You can try NoScript to see if that blocks it.
    *NoScript: https://addons.mozilla.org/firefox/addon/noscript/

  • How to focus two text boxes at a time?

    Hi,
    I am developing a packet analyzer software. In that, I need to focus two text boxes as I select a treeview item.
    I am using a following code:
    delegate void voiDelegate();
    private void click(object sender, RoutedPropertyChangedEventArgs<object> e)
    TreeViewItem t;
    t =(TreeViewItem) tvMain.SelectedItem;
    StackPanel s = (StackPanel)t.Header;
    List<TextBlock> l = new List<TextBlock>(3);
    foreach (TextBlock children in s.Children)
    l.Add(children);
    string ch = l[3].Text;
    string[] sp = ch.Split('-');
    int te = Convert.ToByte(sp[1]) - Convert.ToByte(sp[0]) + 1;
    PacketDisplay1.SelectionStart = PacketDisplay2.SelectionStart = Convert.ToByte(sp[0]);
    PacketDisplay1.SelectionLength= PacketDisplay2.SelectionLength = te;
    voiDelegate giveFocusDelegate = new voiDelegate(giveFocus);
    Dispatcher.BeginInvoke(giveFocusDelegate, new object[] { });
    private void giveFocus()
    PacketDisplay1.Focus();
    PacketDisplay2.Focus();
    but here I am able to focus only on second Textbox. I need to focus on both textboxes. How can I achieve this?
    My requirement is like this
    thank you.

    The documentation is pretty clear on this: There can be only one
    element on the whole desktop that has keyboard focus:
    https://msdn.microsoft.com/en-us/library/aa969768%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396.
    There is logical focus and there is keyboard focus. There can be multiple elements that have logical focus in an application but only a single element can have keyboard focus. Please refer to the link above for details.
    If you want to highlight text in two different TextBoxes at the same time, you could replace the TextBox elements with RichTextBox elements, and set the background of a text range. Please refer to the following thread for more information about how you could
    do this:
    http://stackoverflow.com/questions/18015380/how-can-i-change-the-selected-text-background-color-in-rich-text-box-wpf-c-sharp
    Here is an example for you:
    public partial class Window6 : Window
    private static TextPointer GetTextPointAt(TextPointer from, int pos)
    TextPointer ret = from;
    int i = 0;
    while ((i < pos) && (ret != null))
    if ((ret.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text) || (ret.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.None))
    i++;
    if (ret.GetPositionAtOffset(1, LogicalDirection.Forward) == null)
    return ret;
    ret = ret.GetPositionAtOffset(1, LogicalDirection.Forward);
    return ret;
    internal string Select(RichTextBox rtb, int offset, int length, Color color)
    // Get text selection:
    TextSelection textRange = rtb.Selection;
    // Get text starting point:
    TextPointer start = rtb.Document.ContentStart;
    // Get begin and end requested:
    TextPointer startPos = GetTextPointAt(start, offset);
    TextPointer endPos = GetTextPointAt(start, offset + length);
    // New selection of text:
    textRange.Select(startPos, endPos);
    // Apply property to the selection:
    textRange.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(color));
    // Return selection text:
    return rtb.Selection.Text;
    public Window6()
    InitializeComponent();
    //set text
    PacketDisplay1.Document.Blocks.Clear();
    PacketDisplay1.Document.Blocks.Add(new Paragraph(new Run("some text....")));
    PacketDisplay2.Document.Blocks.Clear();
    PacketDisplay2.Document.Blocks.Add(new Paragraph(new Run("some other text....")));
    //set background
    this.Select(this.PacketDisplay1, 0, 4, SystemColors.HighlightBrush.Color); //select "some"
    this.Select(this.PacketDisplay2, 0, 4, SystemColors.HighlightBrush.Color); //select "some"
    There is no way to achieve this by simply selecting text in two different TextBoxes and there is no way to set the background of a text range in a ordinary TextBox so you must use a RichTextBox here.
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • How to set focus in text box at server side

    Hi,
    I have small problem , i have a text box in form , which is get validated at server side in servlet , if it found some thing wrong then it throws exception , i want that when an exception is thrown it should set focus for that perticular text box. so what should i write to perform such a activity.

    Get hold of the element ID in the servlet (and keep the code conventions) and print it out to some Javascript function which does a focus during the onload.
    There's an example of focus/highlight using JSP/Servlet/Javascript in this article: [http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html]. Also see the screenshots at the very bottom.

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

  • Text box should get focus

    Hi,
              In my jsp page I have a form witho two text fields i.e input type="text"
              These two text fields get the values from scanning. Since scanning
              generates an event enter(it is going to submit the form), so after I scan
              the first value to the first text box, the second text box should get focus
              and after the ticket is scanned to the 2nd text box it should submit the
              form and the focus should return to the
              2nd text box and not the first one.
              Thanks
              Madhu
              

    I got it working
              Thanks
              Madhu
              m holur <[email protected]> wrote in message
              news:3c1f42c7$[email protected]..
              > Hi,
              >
              > It needs a java script, I am having onsumbit focus should be on the
              second
              > text box, but it is not working. I need to know what java script I should
              > use?
              >
              > Thanks
              > Madhu
              > Nils Winkler <[email protected]> wrote in message
              > news:[email protected]..
              > > This sounds like you need to use JavaScript...
              > >
              > > Nils
              > >
              > > m holur wrote:
              > > >
              > > > Hi,
              > > >
              > > > In my jsp page I have a form witho two text fields i.e input
              > type="text"
              > > > These two text fields get the values from scanning. Since scanning
              > > > generates an event enter(it is going to submit the form), so after I
              > scan
              > > > the first value to the first text box, the second text box should get
              > focus
              > > > and after the ticket is scanned to the 2nd text box it should submit
              the
              > > > form and the focus should return to the
              > > > 2nd text box and not the first one.
              > > >
              > > > Thanks
              > > > Madhu
              > >
              > > --
              > > ============================
              > > [email protected]
              >
              >
              

  • Pressing ENTER during text box focus

    When I have clicked and entered text in my text box I would
    like to be able to press ENTER to submit the information (Players
    name) then move to the next frame. Right now I can press enter to
    go to next frame until I my cursor is focused on the text box.
    Please tell me the action script to make pressing ENTER on
    the keyboard work.
    Thanks folks

    I cant find anything that tells me how to disable keyboard
    shortcuts and I dont know what as2 or as3 means?
    My main problem is wanting my user to press enter while
    focused on a text box I need the action script to do that.

  • NO text box focus

    Is there anyway I can make it so that none of the text boxes
    on my slide have the focus when it is loaded; i.e. no blinking
    cursor anywhere?
    I know how to force the cursor into a specific box, but
    couldn't find how to remove the cursor until a user clicked.
    Thanks.

    Hi WestatMSB and welcome to our community from me too!!
    Hi to you too Rick, hope you are keeping well.
    I am going to do the long shaky limb tango here and suggest
    that instead of using all the tech stuff, to simply make a copy of
    the slide with the text boxes on, remove all the text boxes and
    place a click box at the point where you would want the user to
    start the inputs. User clicks on the box, slide show moves on and
    the only change seen is that a cursor starts flashing in the box
    that you have specified.
    Yes, No? Please post back as I am really curious about
    this!!

  • Script that will automaticly set the focus to the next text box after the previous one is completed

    Specificly, entering a SSN into a form with three text boxes. 1st box for first 3 digits, 2nd box for middle 2 digits, and 3rd box for last 4 digits. I would like the user to be able to enter the 1st three digits into the 1st box, and after the 3rd digit is entered, the focus jumps to the 2nd box, then once the middle two are entered, the focus jumps the the 3rd box without having to manually use the tab key to advance through the boxes. Thanks.

    See JavaScript - setFocus Method for tabbing to next form field for a sample form that uses a document level script and custom keystroke script. See Entering Document Scripts and Entering scripts for form fields by Thom Parker for detailed instructions on entering or viewing these type of scripts.

  • Is there a keyboard shortcut to go to the first text box on a page when the focus is on the Location Bar?

    I can use Alt+D to get to the Location Bar to type in a URL, but is there a way I can then go to the default text box, to enter data, once the search engine page has been opened, by using a short-cut key? I didn't recognize any of the commands in the Shortcut Keys page as being what I want.

    This was helpful, but didn't really answer the question. Pressing Tab when I"m on the google Location Bar takes me to the search text box, which is what my motivation for writing the question was, but I notice that on many pages, it doesn't work. This page, for instance.
    I went to the about:config page and changed the <b>accessibility:tabfocus</b> from 1 (tab through every element) to 5 (only tab to the text boxes and links) but it seems to still tab through every element.

  • Dynamic action on text box change does not working

    i have a page with following components.
    a report that has and edit link.
    a text box to catch the primary key from report link when it is clicked
    a number of elements (text boxes, check boxes and LOVs) which are used as data entry form.
    Now my design is that user enter values save them and no sooner did they save, the report depicts new
    values. if user want to edit any record, they click on edit link and the data entry form elements
    should now bring all those values from DB on page. i m successful to pick primary key and bring
    it in a hidden text box and wrote a dynamic action on its change event that will bring values from
    DB and set all page elements. but but but.........the change event doesnt work. it only work
    when focus is lost from the text box...!! offcourse user wont want to click in that "hiddent" text
    box and then click some where else to bring values in page data entry form......
    help is humbly requested from forum or if any other solution approach is to be used easier than
    one i m using, would be appreciated.
    thanks in advance for reading my bore question :)

    bundles of thanks for reply. i m going to elaborate.
    1. My page no is 3.
    2. Hidden Item name is P3_EDIT_ACTIVITY_ID
    3. Data entry form, hidden item and the report are on the same page.
    4. on the edit link of report, i have used following settings.
        Target: Page in this application
         Page: 3
         and i set hidden item as follows......
         Item 1   P3_EDIT_ACTIVITY_ID         Value #ACTIVITY_ID#
       well, when i click the link on report it does bring Activity_Id in the hidden box (which is not yet hidden for debugging purpose)
    Next i wrote Dynamic action which fires on the change event of P3_EDIT_ACTIVITY_ID and run PL/SQL code with in it which is as follows
      declare
      Dept varchar(50);
    begin
       select my_dept into Dept from activity_main ACTIVITY_ID = :P3_EDIT_ACTIVITY_ID;
       :P3_Dept := :Dept;          (i did use :P3_Dept := Dept also but this wont work)
      insert into testdynamic (stamp) values (Dept);  (I did this to check whether correct value is brought from DB, yes it works correctly, correct Dept is being inserted in stamp column)
    end;
      i have created another true action to check when the dynamic action is fired. its very simple alert. and the problem is, it only fires when focus is lost from the P3_EDIT_ACTIVITY_ID. i mean, when u keep changing value inside the text box, nothing happens, when u go outside, the alert is fired and so the pl/sql procedure. but the line
        :P3_Dept := :Dept;       OR      :P3_Dept  := Dept;         arent working which is the actual requirement.
      I m not using set value here as i have to set a lot of values on page not one. further. plz let me get rid of this lost focus thing as i want the form to be populated with correct values related to P3_EDIT_ACTIVITY_ID as the user click on any edit_link in the report.
    Thanks for persistence. i hope i have provided all the details.
    looking forward.

  • Keyword tags text box poorly designed, crashes PSE 8

    I was very interested to see that PSE 8 allows you to enter keyword tags using a text box, as other programs do, promising much faster tagging with large sets of tags.  But the feature has serious bugs rendering it unusable.
    After trying the keyword-tags text box for less than a minute on my large catalog with 426 tags, PSE 8 crashed.    Even with a fresh catalog and the default tag categories, it will crash after using the text box about 40 times.   (See below for a recipe.)
    Another bug concerns tags with commas in them, e.g. "Truckee, CA" (I have a couple hundred such Place tags).  If you type "Tru" in the text box, select the tag with the mouse, and hit enter, PSE 8 will create two new tags, Truckee and CA, in the Other category, and apply them to the photo.
    A design misfeature: After you select and apply a tag with the text box, it loses the keyboard focus.  So to select another tag for the same photo, you have to move your hand to the mouse and click in the text box again.  Partially defeats the whole purpose.
    Recipe for reproducing the bug:
    1. Create a new catalog.
    2. Import 50 photos.
    3. Select the next photo.
    4. In the keyword tag text box, type "p" and then enter.
    5. Go to step 3.
    On the 40th or 41st photo, my PSE 8 reliably crashes (Vista 32, 4 GB of memory).   If after step 1 you use the Keyword Tags > + > From File command to load a tag heirarchy of 210 tags (see the attached file), it will crash after just 9 photos.   And with 426 tags, it crashes after 5 photos.
    Interestingly, on my Vista 64 system (unsupported by Adobe, 8 core x 2.7 GHz), PSE 8 doesn't crash, but the text box gets unusably slow very quickly.  WIth 210 keyword tags in the catalog, it soon takes about 12 seconds to find a tag after you type a unique prefix.   That time gradually gets longer the more you use the text box.  With 426 tags, it takes almost 20 seconds to apply a tag using the text box.
    On both systems, it's clear what the nature of the bug is: Each time you use the text box, the process's memory grows by many megabytes.  I believe my Vista 64 system doesn't crash (at least not immediately) because it provides 3.5 GB of memory for use by PSE 8, while Vista 32 only provides about 1.5 GB.
    I'm getting a sinking feelilng...

    Is the white triangle to the left of "Keyword Tags" pointing down or pointing to the right?  See this screen shot:
    Click on the white triangle -- does that make a difference?
    If not, try deleting the Organizer's preferences:
    http://www.johnrellis.com/psedbtool/photoshop-elements-faq.htm#Delete_the_Organizers_prefe rences

  • Pages 5.1 Text box problems

    In Pages 5.1 when I paste a graphic in a text box (e.g., a PNG file), it no longer stays in the text box.  This was a great feature in Pages '09, the ability to paste a graphic into the text box, add figure legend text, and a line around the whole thing and have it remain as one unit.

    If you still have Pages v4.n located in /Applications/iWork after the v5+ upgrade, I would recommend you revert to an old friend.
    In v5, you insert the Text Box, then from the Format > Style > Fill, you choose Image Fill, Scale to Fit (or Fill), and then Choose.. to pick your image from disk. The Toolbar media choice will just plop an image over the top of your Text Box. Dragging and dropping an image over the Text Box places the image behind the Text Box. This can lead to an interesting crop effect.
    If your image choice will be too dark to see the original black Text Box "Text" placeholder, then you may want to initially choose a lighter font before paragraph 2 above. Othewise, a double-click after the image fill will provide edit focus in the Text Box. A downside is that changing the opacity will effect the image and the text.

  • Minimim characters in a text box

    It seems silly that it is so easy to set the maximum number of characters in a text box (ie. Properties>Options>Limit of X characters) but that there is no easy equaivalent for minimum characters? At least not in Acrobat 9 anyway, don't know about the never versions!
    Does anyone know if the minimum number of characters can be set with Javascript?

    That was intended to be a rhetorical question. So what you really want is if the field is not blank, that there should at least be some minimum number of characters. What is the minimum number that you want to enforce? Youd probably want to use a custom validation script for this, but what exactly do you want to happen if the user only enters three characters but the minimum you want is four? Should the three characters that were entered be rejected altogether, or should the focus just be set back to the field so the user can enter more, or something else?
    Here's what a script that rejects the entry might look like:
    // Custom validate script for text field
    (function () {
        // Allow nothing
        if (!event.value) return;
        // Set the minimum number of characters
        var min_chars = 4;
        // Reject the entry and alert user if fewer than the minimum
        if (event.value.length < min_chars) {
            event.rc = false;
            app.alert("Please enter at least " + min_chars + "characters.\r\rYou entered " + event.value.length + " characters.", 1);

  • Help - text boxes/highlighting hidden unless selected in Acrobat Pro 9.2

    I am working Acrobat Pro 9.2. When I insert a text box, it disappears when I click somewhere else.  I can only tell it's there If I hover over it - I get a black mouse arrow.  If I click on it and select it, then I can see the text and border, but if I click anywhere else, it disappears.  I've tried all the options and settings I can find.  It is set to show, not hide, all comments and text boxes.  Also, when I try to highlight regular text, it puts a little yellow, symbol above my text but does not highlight the text.  When I roll the mouse over it, a yellow note pops up with the text I highlighted, but when I move the mouse away, nothing is highlighted.  Again, I've tried changing all of the settings I can find related to highlighting but nothing works.  I use Acrobat on other computers and have used both text boxes and highlighting without any problem.  Is this due to a setting somewhere, or is there something wrong with my installation of Adobe?   Thanks.

    Something to check.
    To have text selected by the Highlight tool placed into the annotation's pop-up:
    Preferences > select Category "Commenting"
    There are three panes of configuration options.
    --| View Comments
    --| Pop-Up Open Behavior
    --| Making Comments
    Tick the last option (Copy selected text into Highlight, Cross-Out, and Underline comment pop-ups) in the third pane.
    Play with the other options as you may find others that are very useful.
    For form fields:
    Preferences > select Category "Forms"
    In the first pane (General), select "Show focus rectangle".
    In the second pane (Highlight Color) select "Show border hover color for fields".
    Be well...

Maybe you are looking for