Last Q: How to set a focus to a specific text area

Hi, I've got a seemingly simple question, which has turned out to be another real stumper of a problem.
I've got a textpane and a textarea on a panel, which gets displayed when the user presses a button. I want the cursor to be set on the textarea as soon as it is loaded. I've tried the following methods with no luck;
txtArea.requestFocusInWindow();
How do I set the focus onto the textarea rather than the textpane.
Thanks

try this ..
this is setting the focus to a specific editbox within a Jframe
ok
add this to the jbInit method :
contentPane.addFocusListener(new java.awt.event.FocusAdapter()
public void focusGained(FocusEvent e)
contentPane_focusGained(e);
then add this as a seperate method to your JFrame
void contentPane_focusGained(FocusEvent e)
jTextEIN.requestFocus(); // jTextEIN is just the name of the component to be focused
Boris the fly

Similar Messages

  • How to set the focus to a first element in oracle apex 3.2.1  and 3.1.2.00

    Hello ,
    I am using oracle apex 3.2.1 in development env. How to set the focus to a first element of a page.
    thanks/mahesh

    Hi,
    This might help
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/bldr_pgs.htm#CJGJDHCI
    Find "Cursor Focus" from page Display Attributes
    Br,Jari

  • How to set the focus on the new added line in ALV list (OO)

    Dear Friends,
    I have an ALV list based on OO(using alv_grid->set_table_for_first_display), when I click the 'new' button to add a new line, the mouse arrow is always pointing to the first line - not the new created line for user to input!!.
    So how to set the focus (mouse arrow) on the new added line in ALV list for user to input it friendly?
    Thanks a lot!!

    Hello,
    To get the selected line row first we have get all the rows in the internal table.
    When u click on the button when it is creating the new line we have to pass the row number to the call method
    CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->get_selected_rows
       IMPORTING
          ET_INDEX_ROWS  =   <internal table of type LVC_T_ROW > (obsolete)
          ET_ROW_NO      =   <internal table of type LVC_T_ROID > .
    CALL METHOD<ref.var. to CL_GUI_ALV_GRID>->set_selected_rows
       EXPORTING
          IT_ROW_NO  =  <internal table of type LVC_T_ROID>
       or alternatively
       IT_INDEX_ROWS  =  <internal table of type LVC_T_ROW>
          IS_KEEP_OTHER_SELECTIONS  =  <type CHAR01>.
    http://help.sap.com/saphelp_erp2004/helpdata/EN/22/a3f5ecd2fe11d2b467006094192fe3/content.htm

  • How to set the focus to the tabbed pane title?

    Dear Friends,
    I'm using tabbed pane (JTabbedPane) in my application. I have 2 tabbed panes and each contain some text fields and buttons.
    In first tabbed, I have 2 text fields, OK and Cancel buttons. I have to set the focus to the title of the tabbed pane after it lost focus from the Cancel button (focus has to move from Cancel button to tabbed pane title by pressing tab key).
    Could anyone please tell me how to set the focus to the tabbed pane title?
    Thanks in advance,
    Sathish kumar D

    Thanks for your reply.
    Could you please tell me how to set focus for title of the tabbed pane throug FocusTraversalPolicy?
    because usually we set the focus for the component by requestFocusInWindow().
    for example set focust to the button OK,
    btnOk.requestFocusInWindow()likewise could you tell me how to set focus to Title of the tabbed pane?
    Sathish kumar D

  • How I set the Focus in object

    Hello.
    I need set the focus on first object in a JInternalFrame.
    The form JInternalFrame contain a JTabbedPanel and this include object jFormatedTextFields.
    I need when the init form set the focus over first object in the first tab of JTabbedPanel. How I do?.
    Than You

    works OK in this
    (tabbed panes seem to be working OK for focus now, don't know what's changed)
    import javax.swing.*;
    import java.awt.*;
    import  javax.swing.text.*;
    class Testing extends JFrame
      MaskFormatter mf;
      JFormattedTextField ftf;
      public Testing()
        setLocation(300,200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        try{mf = new  MaskFormatter("###.###.##.##");}
        catch(Exception e){e.printStackTrace();}
        ftf = new JFormattedTextField(mf);
        JTabbedPane tp = new JTabbedPane();
        tp.addTab("A",ftf);
        JDesktopPane dp = new JDesktopPane();
        JInternalFrame if1 = new JInternalFrame( "I-F1", true, true, true, true );
        if1.setLocation(50,50);
        if1.getContentPane().add(tp);
        if1.pack();
        if1.setVisible(true);
        dp.add(if1);
        getContentPane().add(dp);
        setSize(400,300);
        setVisible(true);
        ftf.requestFocusInWindow();
      public static void main(String[] args){new Testing();}
    }

  • How to set item focus from javascript

    Hi all,
    i need to validate a form item with javascript to check required fields.
    The function is :
    function isRequired(field) {
    if ($v_IsEmpty(field)) {
    alert('The field is required!');
    html_GetElement(field).focus();
    return false;
    return true;
    Also in the form item attribute i added :
    onChange="isRequired(this);"
    If the filed is null, i see the alert but the focus is on the next item! How can i set the focus on the null item?
    Thanks,
    Sergio

    Denes, thanks for your answer.
    I tried
    html_GetElement($x(field).id).focus();
    but doesn't work.
    Also, if in the form item attribute i add
    onBlur="isRequired(this);"
    instead of
    onChange="isRequired(this);"
    the javascript works with both solution (html_GetElement(field).focus(); or html_GetElement($x(field).id).focus();) with IE7 but doens.t work with Firefox 3.0.1.
    Please help me, please
    Sergio

  • How to set a Focus to a TextField?

    Suppose I have a 3 text field. After entering some data in the first text field, when I press enter key I want to set focus on the next text field. ie., instead of using TAB key I want to operate it using Enter Key. Similarlly, from the second Text field to third text field using Enter Key. Please help me in this event. If possible, please sent me a sample code.
    email id is [email protected]
    Regards
    Suresh Babu
    India

    Suppose I have a 3 text field. After entering some
    data in the first text field, when I press enter key I
    want to set focus on the next text field. ie., instead
    of using TAB key I want to operate it using Enter Key.
    Similarlly, from the second Text field to third text
    field using Enter Key. Please help me in this event.
    If possible, please sent me a sample code.
    email id is [email protected]
    Regards
    Suresh Babu
    IndiaTo send you a sample code, this fucntion is no big deal. It is very easy. I am assuming that you have a listener to each of your textfields. Let us say you have three text fields...textOne, textTwo, textThree.
    In the action listener of the textOne text filed:
    textOne.addActionListener( new ActionListener()
        public void actionPerformed(ActionEvent ae)
          String text = textOne.getText();
          textTwo.requestFocus();
      }So you basically do this for your textOne and textTwo text fields' action listeners.
    Got the concept?
    Vijay :-)

  • How to set  a  focus to a text field when  button is clicked

    [b]in sun stdio creator  setting  a focus is not possible is it a bug
    if  we use  java script
    <ui: button  onClick="focuss(form1:text1)"/>
    function focuss(text1){
        var text=text1;
        text.focus();
    the code is executed but  it is not  working  why[/b]

    Sorry, I didn't read carefully your question. My answer refered to client side only. You can set the focus programmatically with Body.setFocus(). In the appropriate action method or action listener call
    this.body1.setFocus("form1:textField1");
    or maybe
    this.body1.setFocus(this.textField1.getClientId());
    to avoid errors due to changing client ID or save the client ID of the TextField in a private member and call Body.setFocus() in prerender().

  • Can someone explain how to set the focus to a component

    Hello,
    What is the best way to ensure that a component gets the focus with code. I have tried requestFocus and requestFocusInWindow and none of them seems to do there work. The frame containing the components that should get the focus is displayed, the component is focusable so that is not the problem. What I found out is that if the component is deep in a nesting of panes (where the top pane is in the frame) is that calling requestFocus or requestFocusInWindow does not give the component where this focus is called on the focus but either the pane that contains it, one of the parent panes of this pane or one of the components in these panes, in almost all cases the component requesting the focus does not get the focus at all. I always have to write a work around in defining a focus listener for all these panes that transfer the focus back to the component that requested the focus originally, I can't believe that this is the way to ensure that a component has the focus via code. I have searched for documentation but found nothing on what requestFocus(inWindow) is actually dooing (a lot about focus traversibility but I don't want to control this, just make sure that a component gets the focus).
    Again I'm pretty sure that the toplevel window is activated and that the component that requested the focus is focusable (I had created a derived version of the DefaultFocusManager that showed who has focus). Personally I think (and I'm not alone if you do a search in this forum on focus management) that there is either a big problem in the documentation of focus management or that it is still not possible to even try to set the focus on a component in a easy way.
    Marc

    Hello,
    thanks for your reply, here is some example code that illustrates the problem I have (the actual code is to big to show here, which is the raison why I did not posted it here). The code wil create a frame with a JPanel with a JTextField, a 'New' Jbutton and a 'Delete' Jbutton, a tabbed pane in the center ('New' will create a new JPanel, add it to the tabbed pane and set the focus on it, either by calling RequestFocusInWindow() directly or by calling it via InvokeLater (someone on this forum suggested to use this). I changed also the focusmanager to show the component that has the focus when you type something. To test compile and run the program (either with a call to requesteFocusInWindow directly or indirectly (by changing the comments), on my system I get the following behaviour:
    1. requestFocusInWindow called directly
    Start program en type, the tabbed pane has the focus
    Press New and type something, a button has the focus not the created panel
    Press New again and type something, a button has the focus not the created panel
    2. requestFocusInWindow be called indirectly
    Start program and type, the tabbed pane has the focus
    Press New and type, the created panel has the focus (I thought at one moment that I had found the solution there, but alas ...)
    Press New again and type something, a button has again the focus.
    Note that with my real program it is not always a button that will have the focus, sometimes it is a combobox or a TextField (I tried to get this with the example code (the JTextField) but did not succeed.
    Hopes this clarify the problem a little bid, what I want is when the window is visible to set focus on newly created panes (or in the real program on the panel that is selected via the tabbed pane or via a key combination to shift the focus between the panels) but requestFocusInWindow seems to behave unpredicatable. I can't imagine that what I see is a bug so I must make some assumptions which are not valid but I don't see them, btw listening on the WindowListener is I think not the solution because the frame is already displayed when I want to set the focus and I do not use a modal dialog box.
    The example code follows here
    Marc
    * Main.java
    * Created on December 21, 2004, 8:58 AM
    package testfocus;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * @author marc
    public class Main
    static int counter;
    /** Creates a new instance of Main */
    public Main()
    * @param args the command line arguments
    public static void main(String[] args)
    JFrame frm=new JFrame();
    JPanel content=new JPanel();
    frm.setContentPane(content);
    final JTabbedPane paneContainer=new JTabbedPane();
    JPanel bar=new JPanel();
    JButton create=new JButton(new AbstractAction("New")
    public void actionPerformed(ActionEvent ev)
    counter++;
    final JPanel pnl=new JPanel();
    pnl.setName("test"+counter);
    paneContainer.add(pnl);
    pnl.setFocusable(true);
    pnl.requestFocusInWindow();
    /* Either use this or the previous line
    SwingUtilities.invokeLater(new Runnable()
    public void run()
    pnl.requestFocusInWindow();
    JButton delete=new JButton(new AbstractAction("Delete")
    public void actionPerformed(ActionEvent ev)
    int i=paneContainer.getComponentCount()-1;
    if (i>=0)
    paneContainer.remove(i);
    JTextField dummy=new JTextField("Test");
    bar.add(dummy);
    bar.add(create);
    bar.add(delete);
    content.setLayout(new BorderLayout());
    content.add(bar,BorderLayout.SOUTH);
    content.add(paneContainer,BorderLayout.CENTER);
    frm.setSize(300,400);
    FocusManager.setCurrentManager(new DefaultFocusManager()
    public void processKeyEvent(Component component,KeyEvent ev)
    System.out.println("Focus owner"+getFocusOwner());
    super.processKeyEvent(component,ev);
    frm.setVisible(true);
    }

  • How to set the Background Color of a Text Field in a Tabular Report.

    Hello,
    I tried to set the Background Color of a Text Field in a Tabular Report.
    But I was not able to change this colur.
    In the report attributes --> column attributes
    I tried already:
    1. Column Formating -- >CSS Style (bgcolor: red)
    2. Tabular Form Element --> Element Attributes (bgcolor: red)
    but nothing worked.
    Can anybody help me?
    I Use Oracle Apex 2.2.1 on 10gR2
    thank you in advance.
    Oliver

    in "Report Attributes" select the column to move to the "Column Attributes" page. In the "Element Attributes" field under the "Tabular Form Element" region enter
    style="background-color:red;"
    I will also check if there is a way to do this via the template and post here again
    edit:
    in your template definition, above the template, enter the following:
    < STYLE TYPE="text/css" >
    .class INPUT {background-color:red;}
    < /STYLE >
    (remove the spaces after the < and before the >)
    change "class" to the class that the template is calling
    (I'm using theme 9, the table has: class="t9GCCReportsStyle1" so I would enter t9GCCReportsStyle1)
    A side-effect of using this second version is that ALL input types will have a red background color--checkboxes, input boxes, etc.
    Message was edited by:
    TheJosh

  • Set maximum number of line in text area

    Hi !
    I need to limit my text area to 3 lines. How do I do this ?
    I was thinking about character limitation but if the user
    press "enter" 3 times, I'm screwed since it is only 3 characters
    but it bust my 3 lines limit.
    Thx guys !

    You should never limit them to a set number of lines. Go for
    character limitation and test the input value before allowing them
    to submit the form.

  • MC74 : how transfer SOP to PIR for a specific mrp area

    Dear guru ,
    i want to transfer Planning Data of a SOP Version for a single material to Demand Management.
    The copy to Demand is run directly into the plant of the SOP Version.
    I manage MRP Area.
    How can I transfer directly SOP to PIR for a specific mrp area ?
    Thanks in advance

    Hi..
    In  MC87 you have to first create  planning data.. SOP.
    Then if you go to MC74 your planning data will be transferred..
    Ii.e you will get the PIRs automatically from Demand management..
    Hope the above clarifies..
    karthick

  • How to set 'colliding' access restrictions in wrt610n - what are rule preferences?

    Hello. I want to set up access restrictions to one MAC address (my kid's machine) basing on week days. From Su to Th allow less access time while during Fr-Sa afternoons access time should be longer. The question is how to program it in router. I know I can set rules with "allow" and "disable" keyword, but I don't know rules preference.
    When I set (Su-Th 6-21) allowed access time then router automatically denies defined machine internet access outside this time range. The problem is in the power of thus calculated denying time. I want to allow more access time in weekend, so I hoped if I can simply add "Fr-Sa 6-22:30 allowed access time" rule. I hoped that router will regard explicitly set time over inexplicitly set  time but it appears it is not so.
    Does anyone know the rule of rules? What are their preferences/priorieties, iis it possible to stack more rules affecting one MAC address or it is so simple that the first rule "rulez"? Is it possible to set more than one time rule affecting the one machine?
    Solved!
    Go to Solution.

    Agh! Thanks for your reply, it was good incentive to test the problem little more. Now I'm pretty sure that wrt610n algorithm has problem - it lies with power cuts. In my flat, the last internet user usually turns off power board when goes to sleep. After power is resumed router seemed to work flawlessly yet herein lies the problem and I hope I've found solution.
    The tests I have done:
    1. 2 rules (as mentioned in my first post). Kid's machine works (this is day now). Didn't played with rules times. Just turned router off. When router was turned on, two other (parents) machine get internet access while kid's machine didn't! Kid's machine was banned from internet against the rules. Router has proper time set - I checked it's status.
    2. I turned both rules to "disable access" versions (1. disable access Su-Th 21-23:55; 2. disable access Fr-Sa 22:30-23:55). This rules should work almost the same way (the only problem is, that no rule can expand over midnight, so the third rule should be added, banning access from midnigts to early mornings). The router was switched off. Then on. All three machines now has internet access. I hope, router will ban access in the afternoon automatically, as is set
    My deduction. Algorithm bases on time points. When marked time comes, algorithm do, what it should do (but only, if router is powered). When you set "turn internet access on" time (this is "allow rule"), router turns on the access precisely at the chosen moment of time. If router was dead at that time, it doesn't turn the access on however, when power is restored. But when you set "disable rules" in place of "enable rules" I hope it should work and I tested, that this way router gives access after turning it on. Router should disable internet access to the kid's machine at selected time - at least until smart kid does not turn the router off a few seconds before the switch_off time and soon after turn it on But then there is plenty of more powerfull means of control, so I don't worry too much Yet it seems to me, there is a flaw in algorithm, which doesn't run properly after power on.

  • How to set the number of contents in list area of t:selectOneMenu

    Hi all
    Can any one plz suggest me how to fix size of number listed elements in <h:selectOneMenu> or <t:selectOneMenu>.
    I want to set this size to 10 so that i can control dropdown list size, which appeared quite long and shadows large screen area as well.
    Having list size as 10 can make other elements scrollable through scroll bar of the list.

    Hi Friend
    Can you match this result with this result
    javax.servlet.ServletException: /jsp/admin/SubTopic.jsp(89,8) Attribute size invalid for tag selectManyMenu according to TLD
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
         org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
    as per your suggestions i have implemented following code -
                                  <h:selectManyMenu size="10"
                                                 id="topic" value="#{topicCreationBean.subtopic}"
                                                 style="width: 155px; font-size:10px;">
                                                 <f:selectItem itemLabel="-----------All-----------"
                                                      itemValue="None" />
                                                 <f:selectItems value="#{topicCreationBean.subTopicList}" />
                                            </h:selectManyMenu></td>
    Waiting for your reply.

  • How to set Blocking Indicator for product specific TransportationLanes?

    Hi All,
    I'm facing a problem while trying to set the blocking indicator for product specific Transportation Lanes-external procurement.
    How can i proceed on the same?
    I've figured out 2 methods for blocking the product specific TLanes.
    1. using /SAPAPO/TR_TL_TRANSFER_BAPI.
    2. using BAPI_TRLSRVAPS_SAVEMULTI.
    I tried using the BAPI - /SAPAPO/TR_TL_TRANSFER_BAPI, which comes inside the DELETE BAPI - BAPI_TRLSRVAPS_DELMULTI. Although I had passed the parameters reg. external procurement, nothing seemed to be happening in the system. There was no blocking indicator - D(locked and flagged for deletion) set against the subjected TLane. In fact, to my amazement, the BAPI didn't return even a single msg. BAPIRETURN internal table after execution was empty.
    Here, I'm passing:
    (IV_LOGQS) TYPE  /SAPAPO/LOGQS
    (IV_LOGSYS) TYPE  LOGSYS
    (IV_CALLER) TYPE  /SAPAPO/MD_CALLER
    (IT_TR) TYPE  /SAPAPO/TR_TTD_TR
    (IT_TR_X) TYPE  /SAPAPO/TR_TTX_TR
    (IT_TRPROD_SRC) TYPE  /SAPAPO/TR_TTD_TRPROD_SRC    and
    (IT_TRPROD_SRC_X) TYPE  /SAPAPO/TR_TTX_TRPROD_SRC
    I haven't tried on the second method yet. Is there any other programming alternative for setting the blocking indicator of a TLane / multiple Tlanes?
    Could anyone pls explain and guide me on a suitable method to be chosen and the process to be followed, parameters to be passed, etc.

    Hi Sanjay,
                    Use the standard BAPI:  BAPI_TRLSRVAPS_SAVEMULTI2 (according to SCM version you are using)
    to update the deletion flag for product specific T-lane, in this BAPI you have to pass the data to EXTERNAL_PROCUREMENT parameter table in which LOCKED_FLG field is there in which you can pass the "D" for deletion or block flag.
    Also you have to pass the same entries in EXTERNAL_PROCUREMENT_X parameter table of this BAPI.
    If any further help required, refer the documentation of BAPI or let me know.
    I hope this will help you to solve the issue.
    Regards,
    Saurabh

Maybe you are looking for

  • HR Payslip PAn No & bank Ac No

    Hi ABAP HR Gurus, i getting a problem in HR PAYSLIP. here in PAySLIP When PAN No of employee appear then his/her BAnk Ac No does Not appear. and same problem is for bank Ac No. When bank Ac No of an employee appears his/her PAN does not appear. What

  • Form Crashes when error occured !!!

    Hi All , we have an Application Developed on 10g iDS , and Deplyed on Linux suse , but a Strange behavior is coming up ; when any form specific error occured on the form such as (Can't insert null , not allowed value for list item ...) the Forms Serv

  • First PKGBUILD: blobby2-svn

    Hi, this is my first PKGBUILD for the svn-version of Blobby Volley 2. Please test it before I'll put it into AUR: pkgname=blobby2-svn pkgver=375 pkgrel=1 pkgdesc="Blobby Volley 2 - SVN version" url="http://blobby.redio.de/content/de/index.php" licens

  • What is "child processes" if using OS Fetchlet with "em_metric_timeout"?

    On page 330 of document <Oracle® Enterprise Manager Extensibility Guide 10g Release 5 (10.2.0.5) B40007-02>, there are a description of using "em_metric_timeout" with OS Fetchlet as below, Parameter : em_metric_timeout Type : integer Description : Me

  • Redundancy and resilience

    How would u explain the following statement: - "The system shall provide redundancy and resilience for the application interface". I mean from java stand point what steps taken would guarantee such a statement. Any suggestions are very welcome. Well