Setting Focus In Textarea

Ok,
I have a java program I've bundled into a jar and then packaged into a Win32 executable. I have windows associate a particular filetype (.wri) to my program.
When I click a .wri file and open it, it loads data to a textarea. Now when I scroll down the textarea and finally click in the textarea, it resets me to the top of the textarea. Now, if I open the executable first, then go through the program to open a .wri file, I can scroll down to the bottom of the textarea, click in the textarea and I do not get reset to the beginning. I need a way to prevent the resetting of the textarea. I've tried using some of the Window methods for setting Focus, but none seem to work. Any ideas why this is happening via the one way and not the other. I'm open to any ideas. This known bug frustrates many because the .wri files being opened have over 1000 lines of text. Thanks in advance!

i think yu can use setFocus by using lostFocus event.
use Focuslost()

Similar Messages

  • Setting focus in TextArea using AWT

    I have looked at all the documentation for the TextArea in the API and cannot work out how to set the focus in a TextArea when a frame is loaded. Should it go in the constructor? the main method? the TextArea? I have tried to use hasFocus() but nothing is happening. Also how could I launch a dialog box when one of the menu items is selected? I'm trying to write a notepad application in Java. Thanks for any help
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class textpad extends Frame implements MouseListener{
    TextArea inputarea;
    GridBagLayout c;
    MenuBar mb;
    Menu filem, editm, searchm, helpm;
    MenuItem newmenui, openmenui, savemenui, saveasmenui, exitmenui;
    MenuItem undomenui, cutmenui, copymenui, pastemenui;
    MenuItem findmenui, findnextmenui;
    MenuItem helptopmenui, aboutmenui;
        public textpad(String title)
            super(title);
            c=new GridBagLayout();
            setLayout(c);
            setLayout(null);
            setSize(400,300);
            setBackground(Color.gray);
            //set position frame appears in screen??
            TextArea inputarea = new TextArea("Does it work?");
            inputarea.setBackground(Color.white);
            inputarea.getAccessibleContext();
            inputarea.setSize(399,270);
            add(inputarea);
            //set position within frame??
            //add MenuBar
              mb = new MenuBar();
              setMenuBar(mb);
              //Add File Menu to Bar                
              filem = new Menu("File");
              mb.add(filem);
              newmenui = new MenuItem("New");
              filem.add(newmenui);
              openmenui = new MenuItem("Open");
              filem.add(openmenui);
              savemenui = new MenuItem("Save");
              filem.add(savemenui);
              saveasmenui = new MenuItem("Save As");
              filem.add(saveasmenui);
              exitmenui = new MenuItem("Exit");
              filem.add(exitmenui);
              //Add Edit Menu to Bar
              editm = new Menu("Edit");
              mb.add(editm);
              undomenui = new MenuItem("Undo");
              editm.add(undomenui);
              cutmenui = new MenuItem("Cut");
              editm.add(cutmenui);
              copymenui = new MenuItem("Copy");
              editm.add(copymenui);
              pastemenui = new MenuItem("Paste");
              editm.add(pastemenui);
              //Add Search Menu to Bar
              searchm = new Menu("Search");
              mb.add(searchm);
              findmenui = new MenuItem("Find");
              searchm.add(findmenui);
              findnextmenui = new MenuItem("Find Next");
              searchm.add(findnextmenui);
              //Add Help Menu to Bar
              helpm = new Menu("Help");
              mb.add(helpm);
              helptopmenui = new MenuItem("Help Topics");
              helpm.add(helptopmenui);
              aboutmenui = new MenuItem("About Notepad");
              helpm.add(aboutmenui);
         public static void main(String args[])throws IOException
           textpad textpad1=new textpad("Untitled - Notepad");
           textpad1.show();
         public void mouseClicked(MouseEvent e){}
         public void mouseEntered(MouseEvent e){}
         public void mouseExited(MouseEvent e){}
         public void mousePressed(MouseEvent e){}
         public void mouseReleased(MouseEvent e){}
        

    a very curious thing just happened when I ran it. The
    bits of the constructor were being created on the
    screen and the test String "Does it work" flashed up
    then disappeared as the MenuBar was created. I have
    also just changed the layout to null. Do I need to
    re-position my TA? What do you think? Thanks for
    your help by the wayAs long as you can see the TA, you shouldn't need to re-position it. Try changing the bg color. Something tells me that maybe the chars are being painted on in white, so you can't see them because their color matches that of the bg color. I could be wrong, though.
    It is weird to be the one trying to solve somebody else's problem. I was the one getting the answers just a few short months ago...:)

  • Setting focus to a JTextArea using tab

    Hi,
    I have a JPanel with a lot of controls on it. When I press tab I want to
    move focus to the next focusable component. This works fine for
    JTextFields, but when the next component is a JTextArea in a
    JScrollPane then I have to press tab 3 times to set the focus to the
    JTextArea. After pressing the tab key once I think the focus is set to
    the scrollBars of the JTextArea because when I press the up and down
    arrows the textarea is scrolled.
    How can I stop the JScrollPane from getting the focus?
    I have tried to set focusable to false on the scrollPane:
    scrollPanel.setFocusable(false);
    and the scrollBars of the scrollPane:
    scrollPanel.getHorizontalScrollBar().setFocusable(false);
    scrollPanel.getVerticalScrollBar().setFocusable(false);
    But it dosen�t work. Is this a completely wrong way of doing it?
    Please help!
    I use jdk 1.4.1
    :-)Lisa

    Not sure what your problem is. The default behaviour is for focus to go directly to the JTextArea.
    import java.awt.*;
    import javax.swing.*;
    public class Test1 extends JFrame
         public Test1()
              getContentPane().add( new JTextField("focus is here"), BorderLayout.NORTH );
              getContentPane().add( new JButton("Button1") );
              getContentPane().add( new JScrollPane( new JTextArea(5, 30) ), BorderLayout.SOUTH );
         public static void main(String[] args)
              Test1 frame = new Test1();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }

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

  • How to set focus on a custom PO Item screen field when in error?

    Hi All,
    I have an interesting situation that i'm wondering if others have solved.  We have extended the PO item table (EKPO) by adding two new fields.  We then have implemented two BAdI's:  ME_GUI_PO_CUST and ME_PROCESS_PO_CUST to add them to the ME21N/ME22N/ME23N screens and logic to do some validation, via these respective BAdI's mentioned.  Everything works perfectly - with one small issue.  When we are doing some validation via a method on the ME_PROCESS_PO_CUST - and "invalidate" the field (and throw an error) when it is in error - I also want to be able to "set focus" on the field in question (basically: go to the particular tab on the ME* screen and highlight the field).  I have tried using SET CURSOR FIELD *****  within this BAdI (ME_PROCESS_PO_CUST) - but doesn't seem to work.  Has anyone tried to do this and have come up with a solution?  Would be much appreciative if you shared it!!!  Thanks much.
    Cheers,
    Matt
    ERP version that we have is:  ECC 6.0

    Just have a look at oss note 310154 - ME21N/ME51N: Customer-specific check, generating error log.
    In short:
    Add your error messages in EXIT_SAPMM06E_012 (using specific macros).
    Sample code (provided in Oss note) :
      loop at tekpo where knttp eq 'X'.
        loop at tekkn where ebeln eq tekpo-ebeln and
                            ebelp eq tekpo-ebelp and
                            kostl eq space.
          if not tekkn-id is initial.
            mmpur_business_obj_id tekkn-id.
            mmpur_metafield MMMFD_ACCOUNTINGS.
          endif.
          mmpur_message_forced 'E' 'ZE' '777' '' '' '' ''.
        endloop.
      endloop.

  • Back again - set focus

    Hi again,
    I've been struggling with setting focus on each instance of a field within a repeating subform. My subform is limited to 5 instances. Min of 1.
    As the user exits the only textfield in the subform, I have a new instance creating. I want the focus set to the new instance but I have not been able to get anything to work. My latest attempt has been to try to pass a count using the instancemanager to a variable in the setfocus string.
    Here is what I have thus far. I know I need to resolve the node but that process is confusing the heck out of me. I've read and re-read everything I've been able to find but I havent been able to wrap my head around that part successfully.
    Can anyone point me in the correct direction or suggest a better solutions? TIA!
    form1.Account_Client_Information.Long_Title.Account_Long_Title::exit - (JavaScript, client)
    var oSubform = xfa.resolveNode("Long_Title");
    var oNewInstance = oSubform.instanceManager.addInstance(1);
    xfa.form.recalculate(1);
    var count = (this.instanceManager.count)
    xfa.host.messageBox("Text Field Index in new Subform: " + count);
    var vfocindex = xfa.resolveNode("Account_Long_Title[count]");
    xfa.host.setFocus(vfocindex);

    Hi,
    The addInstance method will return the subform that you want so you only need to do;
    var oNewInstance = Subform1.instanceManager.addInstance(1);
    xfa.host.setFocus(oNewInstance.Account_Long_Title)
    Regards
    Bruce

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

  • Setting focus in a PDF form

    Hi,
    I'm trying to move a cursor to a particular field based on certain conditions using JavaScript. The method I am using is xfa.host.setFocus("fldTest"); in the initialize event. For some reason the focus isn't getting set to fldTest, but when I first hit tab it goes into the first field that is in the tab order. Is there any way around this?
    Thanks,
    Chad

    You might want to check the reference path of the field that you want to set focus on.
    Ex: xfa.host.setFocus("form1.page1.subform1.TextField1");

  • Setting focus to new instance of a field...need help.

    Hi there,
    I have a flowed form which consists of multiple subforms. I have one subform which is basically one textfield that is set to a min of 1 and a max of 5.
    These are to correspond to fields in our system of record that have 5 fields for company long name with a 36 character field limit.
    I've got the limits set up just fine and I have added simple script to add a new instance when the user exits the field.
    The focus goes to the next field set in the tab order but what I want is the focus set on the new instance of field created but I have not been able to find an example of how to do that.
    Any suggestions would be greatly appreciated. Thanks!

    Well,
    I've been reading and trying various things but cant get anything to work like I want it to.
    The sample provided works for 2 iterations but mine has to do this for up to 5 instances. I have not been able to figure out how to get this to work.
    Anyone have any additional suggestions?
    btw...here is my modified version. ES2 is whay I'm using.
    Long_Title.occur.max = "5";
    var oSubform = xfa.resolveNode("Long_Title");
    var oNewInstance = oSubform.instanceManager.addInstance(1); // I think you probably managed this first part better than here
    xfa.form.recalculate(1); // I THINK THIS IS IMPORTANT
    var count = (this.Long_Title.nodes.length)
    var testIndex = oNewInstance.Account_Long_Title.index;
    xfa.host.messageBox("Text Field Index in new Subform: " + count); // TextField1 will conserve index 0 because it is the only textfield in the new Sub1
    var NEW_TEXTFIELD = xfa.resolveNode("Long_Title[1].Account_Long_Title[0]"); // However, Sub1 gets index 1 because it is not alone any more
    xfa.host.setFocus(NEW_TEXTFIELD); // This actually sets focus on the newly created instance of TextField1 (actually Sub1 instance)

  • Change and set Focus of window

    HI
    Guys
    I have encountered a problem while setting focus of my application's windows.
    i found the way i.e. by
    public void windowGainedFocus(WindowEvent wgf) {          
              if(this.isActive()){
                   VWM.theVWMDetailWindow.setAlwaysOnTop(true);
                   System.out.println(wgf.getSource());
         }by doing that there is errors came.....
    but there is no effect on the window theVWMDetailWindow to have operation setAlwaysOnTop successfully functoned
    Please help me out
    Thanks

    HI
    Yannix
    actually , i want to get the focus of my application window
    and then perform the action on it..
    The case is that::
    I have a main window..then on it a menu bar...
    when i click on one of the menu option then another separate window will be opened....and many other windows on different menu options....
    SO now i want to control their focus..... rite
    when my main window's focus lost means if i select another application
    another related opened window's must also lost their focus at that time.and when i came back to the main window another window's already opened must be on top.....
    So could you please suggest me some way , some solution to solve this
    Thanks

  • Setting Focus to datagrid next Item renderer column

    Hi
    I am having spark datagrid with 7 colum, I am facing problem to set focus for item renderer element.
    Below is my datagrid, when user enter some text in text input and press TAB key, I want trade button to be in focus. and from trade column Tab key press I want delete button to be in focus.
    I tried giving
    tabEnabled="true" tabChildren="false" tabFocusEnabled="true" editable="true" hasFocusableChildren="true"
    for datagrid.
    Also i tried giving selectedCell
    var _focusedCell:Object = new Object();
                                                                _focusedCell.rowIndex = dgTermDepo.selectedIndex;
                                                                _focusedCell.columnIndex = 5;
                                                                dg.selectedCell = _focusedCell as CellPosition;
    but nothing is working, I know I am missing some logic or property, Please suggest me on this
    Thanks
    Sonu

    You need to dig down into the event object and look at the
    listData.
    public function clickMe(e : MouseEvent ):void {
    var rowIndex : int = e.currentTarget.listData.rowIndex
    var colIndex : int = e.currentTarget.listData.columnIndex
    if the listData object is null when you try this you may need
    to add the following methods as overrides to the renderer or create
    a base renderer and extend all your renderers from the base
    renderer so that you always override these methods.
    [Bindable("dataChange")]
    private var _listData : BaseListData;
    override public function get listData() : BaseListData {
    return _listData;
    override public function set listData( value : BaseListData )
    : void {
    _listData = value;
    }

  • Setting focus to inputText of newly created row in af:table

    Using Jdev Ps4
    Simple use case:
    I have an af:table with a few columns and a createInsert button.
    When I press the createInsert button, a new record is added to the table.
    How can I set focus to the first inputText of that newly created row?
    I have been looking for a solution online but all the examples online tell us how to set focus to components that already exist and you know the ID of. With the newly created row, you don't have the ID so you cannot set the focus.
    In this topic (which is quite old...) https://kr.forums.oracle.com/forums/thread.jspa?threadID=643924 Frank Nimphius explained that it would be difficult and he would pass it on to the developers.
    I haven't found any information if there are some enhancements in this area to make this work...
    I tried with using plain old javascript by looping through the dom structure but had no success in doing so...
    Thanks
    Yannick
    Edited by: Yannick Ongena on Apr 2, 2012 8:38 AM

    Yannick,
    can you check this?
    how to get focus on newly created row in table?
    ~Abhijit

  • Set focus in tabular form

    apex 4.2
    I trigger javascript on a page with a tabular form.
    after the javascript fires the page reloads.
    I tired setting a dynamic action on page load that
    set focus
    jquery selector
    [name=f02]:last
    which should set focus to the f02 field of the last record in the tabular form..
    but it doesnt work..
    any other ideas
    I just want the focus to go to the bottom of the page

    nevermind, found a way that works..
    in javascript
    $('input.addfocus:last').focus();in column element attribute: class="addfocus"

Maybe you are looking for

  • [solved] missing latest backups for iPhone after getting replacement phone

    Thought I would share this one in case anyone else runs into it. My the speaker on my wife's iPhone 4 on Verizon had stopped working for phone calls for the second time and a restore didn't fix it, so she returned the phone and they gave her a new on

  • Macbook Pro stuck at the login screen

    This morning I dropped my laptop by catching the charging cable the laptop fell on the floor but everything seemed to be normal. I then decided to back up straight away so I started time machine. I stupidly started doing some user instensive things o

  • MacBook Pro restarts unexpectedly after removing mini displayport-DVI adapter

    Hi all, I did a clean install of Mavericks a little while back. Since then I have been noticing an issue with my Mid-2009 17" MacBook auto-restarting, and have reduced it when I remove my mini displayport-DVI adapter. I usually work with my macbook c

  • How to change the name of External Hard Disk?

    I am new to Mac so if this is really easy and I am being completely lame here please excuse me. I have an External Hard Drive that is being used by Time Machine. I don't want to see it on the desktop so I was going to change the name so it had a '.'

  • [SOLVED]cURL got problem uploading file with "[]" in the name

    $ curl -# -iv -u username:passwd -T '[gg].png' 'ftp://ftp.liondrive.com:2221' curl: (3) [globbing] error: bad range specification after pos 2 When I rename [gg].png to gg.png, it's all just fine. Anybody encountered same thing? What's the problem? La