How to set focus on a Component?

I'm doing a simple DATA ENTRY program. My web apps contains the ff:
- 4- buttons (add, save, undo, del)
- table
To avoid mistakes on the data entry by a user. I make it a point to limit possible areas of risk. Like:
ie: when addButton is clicked.
- we set addButton.setDISABLED(true)
- also we set delButton.setDISABLED(true)
Problem: On the web browser, we get an error that saysn "Can't move to the focus control ... blah, blah blah"
How do I set the focus on other control?

I suppose this is a javascript error.
If you are using firefox, could you please add what the error is that you are seeing.
How are you trying to set the focus on the other button?
You could try adding javascript code to onclick functionality of the button you are disabling.
something like:
onclick = "<client id of the button to have focus>.focus()";

Similar Messages

  • How to set focus to required component in the application

    Hi all,
    Based on user events, I want to set focus dynamically to required component/panel in the application.
    Is this possible? is yes, pls give me api for that!

    [http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JComponent.html#requestFocusInWindow()]
    A panel is not focusable by default.
    If you want a panel to get the focus you have to use panel.setFocusable(true) first.

  • How to set Focus for one component on Dialog

    Hi all.
    I have a problem and need a help
    I have a JDialog
    I add some components on it. Includes button, textfield...
    after i set
         _textField.requestFocus()When Dialog show, it always focus at first component, not at the component i set.
    Please help me.
    Thanks in advance
    Diego

    Perhaps Swings threading ruins your focus request, and trying invokeLater may be worthwhile...
    Note that [requestFocusInwindow()|http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#requestFocusInWindow()] is to be preferred over requestFocus according to the API docs.
    Edited by: isocdev_mb on Mar 4, 2010 6:05 AM

  • How to set focus order of multiple Component in a Frame

    I have created a Frame with contain some Label, Textfield, Choice and Buttons
    How do set focus order on these Components

    write an implementation of
    import java.awt.*;
    public class PanelFocusTraversalPolicy extends FocusTraversalPolicy
        public Component getComponentAfter(Container container, Component component)
            if(component.equals(cmp1))
                return cmp2;
            if(component.equals(cmp2))
                return cmp3;
            return cmp1;
        public Component getComponentBefore(Container container, Component component)
            //implentation of method
        public Component getDefaultComponent(Container container)
          return cmp1;
        public Component getLastComponent(Container container)
            return cmp3;
        public Component getFirstComponent(Container container)
           return cmp1;
        public PanelFocusTraversalPolicy()
    }and set the focus traversal of frame.
    setFocusTraversalPolicy(new PanelFocusTraversalPolicy())

  • How to set focus on UI Element

    Hi All,
    I am using the below code to set the focus on the first row of the table given in the link  [How to set focus at UI element ? ] on enter of an event.
    data: lr_elem type ref to if_wd_view_element.
    lr_elem = view->get_element( <ID of the Link to Action field>).
    if lr_elem is bound.
    view->request_focus_on_view_elem( lr_elem ).
    endif.
    I am getting "Cannot use NULL reference as object error at view".
    Can you please tell me how to get the reference of the "view".
    Thanks
    Praveen

    >
    praveenkumar_81 wrote:
    > Hi All,
    >
    > I am using the below code to set the focus on the first row of the table given in the link  [How to set focus at UI element ? ] on enter of an event.
    >
    >
    data: lr_elem type ref to if_wd_view_element.
    > lr_elem = view->get_element( <ID of the Link to Action field>).
    >
    > if lr_elem is bound.
    > view->request_focus_on_view_elem( lr_elem ).
    > endif.
    >
    > I am getting "Cannot use NULL reference as object error at view".
    >
    > Can you please tell me how to get the reference of the "view".
    >
    > Thanks
    > Praveen
    Hallo Praveen,
    have you controlled that id of the Linktoaction ? there you made error.
    See it in the ViewElement designer .
    should be something like this
    lr_elem = view->get_element( 'LTA_name ' ).

  • How  to set focus on next row inputfield in table

    Hello all,
    How  to set focus on next row input field in table
    Please help.
    Thanks in advance.
    CSP

    Hi,
    use the following code
    wdThis.wdGetAPI().requestFocus(nodeElement, attribute)
    Ex:
    Provide the attribute and replace the nodeElement with that of yours
    IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("Your attribute");
           wdThis.wdGetAPI().requestFocus(wdContext.currentContextElement(), attributeInfo);
    Regards
    Ayyapparaj

  • How  to set focus on an element inside a datatable on load

    How to set focus on an element inside a datatable on load

    Check out https://blogs.oracle.com/groundside/entry/ever_wondered_how_uncommitteddatawarning_works and
    Decompiling ADF Binaries: Checking for dirty data
    Timo

  • How to set focus on the last row of JTextPane

    how to set focus on the last row of JTextPane?
    import javax.swing.*;
    import javax.swing.text.html.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MyGUITest extends JPanel implements ActionListener
    {   public static void main(String[] args)
        {   SwingUtilities.invokeLater(new Runnable()
             {   public void run()
              {    JFrame f = new JFrame("My GUI");
                  MyGUITest GUI = new MyGUITest();
                  GUI.setOpaque(true);
                  f.setContentPane(GUI);
                  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  f.pack();
                  f.setLocationRelativeTo(null);
                  f.setVisible(true);
        JTextPane txtP;
        JButton add;
        HTMLEditorKit hek;
        HTMLDocument hd;
        String txt;
        MyGUITest()
        {     this.setLayout(new BorderLayout());
         this.setPreferredSize(new Dimension(400,200));
         txtP = new JTextPane();
         txtP.setEditable(false);
         txtP.setContentType("text/html");
         txtP.setText("");
         hek = new HTMLEditorKit();
         txtP.setEditorKit(hek);
         hd = new HTMLDocument();
         txtP.setDocument(hd);
         JScrollPane sTxtA = new JScrollPane(txtP);
         add = new JButton("add");
         add.addActionListener(this);
         sTxtA.setBorder(BorderFactory.createTitledBorder(""));
         this.add(sTxtA, BorderLayout.CENTER);
         add(add, BorderLayout.SOUTH);
         new Thread(new Runnable()
         {   public void run()
             {   while(true)
              {   try
                  {     Thread.sleep(100);
                  }catch(InterruptedException ex)
                  {     ex.printStackTrace();
                  appendText("This is <b>HTML</b> text");
                  //add.doClick();
         }).start();
        public void actionPerformed(ActionEvent e)
        {     txt = "<b>asd</b>";
         try
         {   hek.insertHTML(hd, hd.getLength(), txt, 0, 0, null);
         }catch(Exception ex){   ex.printStackTrace();   }
        public void appendText(String txt)
        {     try
         {   hek.insertHTML(hd, hd.getLength(), txt, 0, 0, null);
         }catch(Exception ex){   ex.printStackTrace();   }
    }thanks~

    anIdiot wrote:
    im not sure what is the caret location...So don't youthink you should have looked for it in the API?
    anyway, i want the scroll bar to scrolled down automatically when the output is displayed.
    normally, the scroll bar is scrolled down automatically when a new text is inserted, but it doesnt work on this timeGo through camockr's http://tips4java.wordpress.com/2008/10/22/text-area-scrolling/
    db

  • How to set focus programmatically in a table ?

    Sir,
    How to set focus programmatically in a table using javascript?
    Is it document.getElementById('form1:table1:i:column1').focus(); ?
    Thanks
    Stephen

    Repost

  • How to set focus on component guaranteed?

    Hi All,
    I want to run my swing based application on win NT OS with JDK1.5. Now i need to set focus on my JFrame window (this is my requirement) but smetime it focussed and sometime it fails. So i need some guaranteed solution or approach so that it focus on my JFrame window i tried so many methods like requestFocusInWindow(),
    requestFocus(),setFocusable() etc. But my application sometime doing expected behavior and sometime fails.
    Can anybody suggest me 100% guaranteed approach? I appriciate any ideas.
    Regards,
    Pradeep
    Edited by: pradeep_dubey on Mar 17, 2009 6:52 AM

    But my application sometime doing expected behavior and sometime fails.Almost certainly a concurrency issue. Are you aware of Swing's single threaded rule, and have you taken care to create and update all Swing components on the EDT?
    [_Threads and Swing_|http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html]
    [_The Last Word in Swing Threads_|http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html]
    db

  • How to set focus and mark red on certain select option field

    hi experts
    I embedded a select_option view in my application and  tried to use IF_WD_SELECT_OPTIONS->request_focus to set focus on a certain select option field if the logical check failed, and also hope the low field of the select option can be marked red....but things does not happen that way....
    could anyone kindly tell me how to implement that requirement?
    tkx and regards
    sun

    What is the problem you are facing in this ?
    Requesting focus is easy.
    just call the method request focus and pass the id of the parameter whose lower value field you want to focus.
    as shown below.
    code you might have written in wddoinit
    DATA: LT_RANGE_TABLE TYPE REF TO DATA,
            RT_RANGE_TABLE TYPE REF TO DATA,
            READ_ONLY TYPE ABAP_BOOL,
            TYPENAME TYPE STRING.
        DATA: LR_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER,
            L_REF_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.
    *   * create the used component
      L_REF_CMP_USAGE = WD_THIS->WD_CPUSE_SELECT_OPTIONS( ).
      IF L_REF_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
        L_REF_CMP_USAGE->CREATE_COMPONENT( ).
      ENDIF.
        WD_THIS->M_WD_SELECT_OPTIONS = WD_THIS->WD_CPIFC_SELECT_OPTIONS( ).
        WD_THIS->M_HANDLER = WD_THIS->M_WD_SELECT_OPTIONS->INIT_SELECTION_SCREEN( ).
    LT_RANGE_TABLE = WD_THIS->M_HANDLER->CREATE_RANGE_TABLE( I_TYPENAME = 'ZDEALERID' ).
    * * add a new field to the selection
      WD_THIS->M_HANDLER->ADD_SELECTION_FIELD( I_ID = 'ID'
      IT_RESULT = LT_RANGE_TABLE I_READ_ONLY = READ_ONLY ).
    code for focusing a field.
    wd_this->m_handler->request_focus( i_id = 'ID' ).
    you must have declared attributes m_handler and m_wd_select_options type reffering to IF_WD_SELECT_OPTIONS and
    IWCI_WDR_SELECT_OPTIONS respectively.
    and regarding that red color i am not sure it is possible without using message manager.
    thanks
    sarbjeet

  • How to set focus on a textfield within a tabbedpane?

    Hallo i have the following problem,
    jTextFieldMyTextField.setText("BlaBla"); -> put the string in the TextField
    jTextFieldMyTextField.requestFocusInWindow(); -> don't set the focus to the TextField
    how i must set the focus?
    Any help is appreciated

    Archana1604 wrote:
    You need not use requestFocusInWindow to set the focus for a component. You can simple use requestFocus() inorder to set the focus.Please read the API and don't post bad advice.
    JComponent#requestFocus
    Note that the use of this method is discouraged because its behavior is platform dependent. Instead we recommend the use of requestFocusInWindow(). If you would like more information on focus, see [How to Use the Focus Subsystem|http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html], a section in The Java Tutorial.
    db

  • Setting focus on a component from backing bean

    Is there an easy way to set focus in a specific component on the jspx from a method in the backing bean? (other than javaScript coding...)

    Hi,
    did you take a look at
    About control the cursor position in a JSF web page
    It contains some links to other weblogs. The links are helpfull. Maybe you'll be able to find your solution there......
    Good luck
    Luc Bors

  • How to set focus on a input field in a selected row of a table?

    In a previous discussion (http://scn.sap.com/thread/3564789) I asked how to access an input (sap.m.Input) field of a selected row in a table. In the answer that was supplied I was shown how to get the items of the table. Then using the selected index to get the selected item get the cells. Then I could set editable on the proper cell(s). This worked fine.
    Now I need to set the focus on one of the fields. I tried something like this:
                var oNewLink = table.getSelectedItem();
                var oNewLinkName = oNewLink.getCells()[1];
                oNewLinkName.focus();
    But this doesn't seem to work.
    I have searched through other discussions and have seen this technique for putting focus on a field if you have its ID:
    sap.ui.getCore().byId(id_of_the_input_field).$().focus();
    In my case though I do not have an ID since the row and its cells are generated. How can I set focus on the cell of a certain row in a table?

    Hello Venkatesh. Yes that code does work. First I tried it on a table cell that was already rendered and it did work. The next time I tried it on a table row that was being added and it did not work there. So I added an on after rendering function for the table and added that code there. That did not work until I added a delay (timeout) to do a context switch before calling the focus and that worked.
    Once last thing though sometimes when I call focus on an input field (actually in a table row cell) if the field has text in it already the flashing cursor is at the beginning of the text and other times it is at the end of the text (which is the desired way). It depends on where I click in the row. Is there anyway to make sure the flashing cursor is at the end of the text when the focus is applied to a field that contains text?

  • How to set focus on the title of JTabbedPane

    I have created a JTabbedPane and added three JPanels to it. They are titled, say "Panel 1", "Panel 2" and "Panel 3". And each of them contains buttons and text areas. Since this app is for physically disabled users, it must provide navigation through these three tabs with keyboard operations only (i.e. without mouse clicks).
    When the title "Panel 1" gets focused, users can go to "Panel 2" by the right arrow key. When Panel 2 is brought up, however, the title "Panel 2" does not get focused. Instead the first button inside panel 2 is focused. In order for users to navigate to 'Panel 3" by the arrow key, the title "Panel 2" has to be focused. How do I set focus on the tab title?
    I have tried 'requestFocus()' on Panel 2, but it does not work. Please help me with this issue. Thanks in advance.

    I'd be quite interested to know if this can be doen as well so I thought I'd post this message to move it to the top of the board.
    Thanks.

Maybe you are looking for

  • Error message when trying to install Flash 10.0.45.2

    I am running IE 7 on windows XP. We had some issues with Flash active active control version 10.1.53.64 and higher so I unistalled 10.1.53.64 and downloaded the older version (10.0.45.2) from the adobe website but when I try to install it I get the f

  • My iphone no longer displays anything through the HDMI connector

    I purchased a cheap 30-pin to HDMI connector (big mistake) but was able to see my iPhone screen on my TV.  I then added a Lightening to 30-pin connector so I could display my girlfriend's iPhone 5C screen on the TV.  But I had problem taking these tw

  • Changing Language in 6120

    Hi all I am having trouble with changing language in 6120. Usually, I am use to change language by pressing the # key when i write some thing... BUT the thing is that in 6120, it will change the language only to the language you choose. E.G main lang

  • Need help setting up a shared /Library/Fonts folder for font sharing

    Hi, I have a problem setting up a shared /Library/Fonts folder on my OSX 10.5.5 server that gets automounted on the OSX 10.5.x clients. While I managed to get the folder to show up automatically under /Network/Library/Fonts on the clients, the fonts

  • File2Idoc - Error [EDI: Partner profile inbound not available]

    Hi All, I am executing file to Idoc Scenario, It is picking the file from sender & delivering to Idoc as well (fields) in R/3 system and showing chequered flag SXMB_MONI. But If go to WE02 in R/3 : It is showing that Partner Profile not availbe , I h