JTextField:  How to selectAll() AND Position Cursor at Beginning of Text

Hi All,
I have a problem with when a JTextField is selected, I cannot simultaneously selectAll() and position the cursor at the beginning of the text. (selectAll() positions the cusror at the end of the selected text, not the beginning, which is what I require).
Does anyone have a solution for this as I haven't found an answer as of yet.
Many thanks.

Thanks uncle_alice, but as far as I have determined, the setCaret() and selectAll() methods are mutally exclusive. Why do people ask for help and then disagree with the answer given?
Thanks uncle_alice, I tried the code and it works.It amazes me that it took half an hour to "try" the code. Why not try the code first, ask a followup question later if it doesn't work? Why do we have to waste time resonding to a question twice, just to get you to try the code?

Similar Messages

  • How to setup and position resizable Scroll Bars in Java ?

    I seem to be asking a trivial question -
    I having MFC code below, how to convert it to Java ?
    For a given bigger image_dims and smaller view_dims -
    MFC code below sets-up and positions the ScrollBars.
    What is the corresponding class and member functions in Java ?
    Thanks A LOT for any help !
    Roman Kazinnik
    ====
    sc_info.fMask = SIF_DISABLENOSCROLL | SIF_ALL;
    sc_info.nMin = 0;
    sc_info.nMax = image_dims.size.y-1;
    sc_info.nPage = view_dims.size.y;
    sc_info.nPos = view_dims.pos.y - image_dims.pos.y;
    child->SetScrollInfo(SB_VERT,&sc_info);
    kdu_coords step = view_dims.size;
    step.x = (step.x >> 4) + 1;
    step.y = (step.y >> 4) + 1;
    kdu_coords page = view_dims.size - step;
    child->set_scroll_metrics(step,page,image_dims.size-view_dims.size);
    ====

    hi lev,
    check this document for jco pools
    http://www.winfobase.de/lehre/lv_materialien.nsf/intern01/FB09D79A41930E34C125709F0046180C/$FILE/Tips&Tricks_JCo_Programming.pdf
    ravindra

  • Validation of JTextField to accept negative and positive values

    Hi,
    I have a question. I have a jTable populated with the fieldname
    in the first column and datatype in the second column.
    I would like to place a JTextField component in the frame
    depending on the data type. So, if a row is selected in the table, the
    datatype of that fieldname is retrieved and depending on that data type
    I want a JTextField to be displayed.
    Now, if the data type is of Integer type, I want the JTextfield to
    accepts Integers only(positive). I have created a class that extends JTextfield.
    But, I want the text field to accept negative integers also. Can anyone please guide me ?

    Hi,
    I wrote an extension of JTable that provides better rendering and editing support for:
    Color
    Font
    Locale
    Integer
    int
    Long
    long
    Short
    short
    Byte
    byte
    BigInteger
    Double
    double
    Float
    float
    BigDecimal
    and some more
    To allow only positive values for the type integer you could use:
    JXTable myTable = new JXTable(...);
    myTable.setDefaultEditor(Integer.class, new IntegerCellEditor(0, Integer.MAX_VALUE, <some locale>));The number editors are based on JFormattedTextField.
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JXTable.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/IntegerCellEditor.html
    Homepage:
    http://www.softsmithy.org
    Download:
    http://sourceforge.net/project/showfiles.php?group_id=64833
    Source:
    http://sourceforge.net/cvs/?group_id=64833
    For more information about the number fields have a look at he following thread:
    http://forum.java.sun.com/thread.jspa?threadID=718662
    -Puce

  • How to cut and paste long Word document into text generator?

    I have a very long list of attributions in a Word document.
    When I cut and paste it into the "Sample Text" area, it goes in fine.
    But when I try to look at it ... either as simple text or, preferred, scrolling ... I only get parts of the document.
    I can correct it by adding a 'return' in the middle of every few words.
    But my document is so long, it would take a long time to do that one by one.
    Solutions sought: How to just import the whole document and have it scroll, zip-zip?!

    Thank you DH and skalaki, I had not known of the Boris title generator. Funny, I had looked in the FCE online manual until 'titling' and editing text ... didn't see mention of that.
    In any case ... I've now found it and trust I'll be able to figure it out.
    Since skalaki was first with the answer, I awarded the 'solved' there. DH's comments were further helpful.

  • [Solved] How do I delete from cursor to beginning of line in Vi?

    I'm wondering if there's a way to delete from the the cursor to the beginning of the current line in Vi, basically doing D backwards.  I would find this very useful, as manually doing this is getting annoying.
    Edit: Of course after days of searching I figure it out right after asking.  It's d0 that I need to type in.
    Last edited by zenten (2012-06-13 17:42:45)

    I saw your thread title and that it was already solved, so I gave myself a little quiz to see if I knew the answer before reading what you wrote.
    Since I use 'd$' to delete to the end of the line, I guessed that it was 'd0' to delete to the beginning of the line. Looks like I was right! Who says Vim isn't intutitive?
    I didn't even know about the 'D' command...

  • How can I get the cursor's position in a opened file and display a menu?

    Hello,
    I want to make a program by which I will be able to display a panel/pops up menu at the corsor's current position, (In any text/doc file or in the desktop, we can display a menu by right click of the mouse.) Now I want my program to do the same task.
    More clearly-
    1. First I would save some words or sentences in a file(aa.txt).
    2. Then I would open another text file/ a word/ excel/ or any other editor( bb.txt / cc.doc / dd.xls / ee.html ).
    3. While editing or writing something in the opened file, if I click the right mouse button/ press a key (ctrl+space), a menu will appear containing the sentences I saved in the file(aa.txt) previously.
    My program will tell me the cursor's position in bb.txt / cc.doc / dd.xls / ee.html that i opened. And display a menu. my problem is not reading / writing in a file.
    My problem is how can I get the cursor's position in a opened file display a menu at that position by a mouse/key action*.
    Would you please help me on this regard.
    Thanks

    DrClap wrote:
    I think the OP wants to start up an application like MS Word and then operate it from a Java program.Doesn't The Monkey's Paw do that? What a second, according to Wikipedia:
    [http://en.wikipedia.org/wiki/The_Monkey%27s_Paw]
    <quote>
    ...the paw of a dead monkey is a talisman that grants its possessor three wishes, but the wishes come with an enormous price.
    The moral of the story is contained in this description of the paw: "It had a spell put on it by an old fakir," said the sergeant-major, "a very holy man. He wanted to show that fate ruled people's lives, and that those who interfered with it did so to their sorrow."
    </quote>
    So I guess that a non-sequitor ... or is it?

  • How to get the current cursor position in word report?

    I am generating a word report. But I would like to keep the table in one page. However, I did not find the way to do it in labview. Somebody would give me some suggestions? I appreciate a lot.
    One way I think I can do is to find the current cursor position. Since I know the table size so I can figure out if the left space in the current page is enough to hold the table. But I do not know how to locate the curent cursor position in word document in labview programmatically. I appreciate any suggestions on this question.
    Thanks.

    Hi,
    when you insert data in a word document you have to refer to bookmarks rather than cursor position.
    If you are using the Report Generation Toolkit for Office it is explained in the manual chapter 3-1.
    See also the example: Generate Report From Template (Word).vi included in the toolkit.
    If you aren't using the toolkit, you still have to refer to bookmark as reference points to insert and/or fetch data.
    The principle is:
    - First create a document in which you insert bookmarks where you wish and save it as a template
    - In LV open your template document and insert in it your data referring to bookmarks as insertion points
    - At the end save your report with another name, so you still have the template
    I hope I have been clear enough, if not just as
    k!
    Good luck,
    Alberto

  • How to Set Position Cursor Option to Non key fields in Table Maintenance .

    Hi,
    I have created a Ztable and i am using table maintenance for that table. In TMG ,by default  we have position cursor option to key fields only . User wants that position cursor option for non key fields also. Please help me out of this issue .
    How to provide Position Cursor option to Non key fields.
    Thanks & Regards,
    Prasad.

    Hi Nabheet,
    I tried using TYPE S DISPLAY LIKE E and am setting vim_abort_saving as X and sy-subrc as 4. However, this is also not enabling the fields. In this case, the first 2 fields - key fields are getting enabled but not the required ones. The above snapshot is for the same.
    lv_date1 = table1-date1.
       lv_date2 = table1-date2.
       lv_diff = lv_date2 - lv_date1.
       IF lv_diff LT 0.
         CLEAR: lv_err_msg.
         lv_err_msg = text-005.
         MESSAGE lv_err_msg TYPE 'S' DISPLAY LIKE  lc_e.
         vim_abort_saving = lc_x.
         sy-subrc = 4.

  • How to export layer width, height, and position to a text document?

    I am working on an automated workflow for which I need to know the exact width, height, and position in pixels of certain layers in a PSD.
    I am pretty sure this is possible with applescript but does anyone know of a way to have this info included automatically in the documents metadata?
    thanks,
    ryan

    Hi Gabriele - how did you add the subs to FCP? if you added them using the text tools built in then you need to try to extract those first. Neither FCP or DVDSP are good places to create subtitles, but apps like STL Edit and Belle Nuit are. These will both create subs that can be imported into DVDSP. You can also use a text file to import the subs as long as the text file is set up correctly. The precise format is listed in the manual for DVDSP and a tool like BBEdit is ideal if you want to do the subs this way. Some folk even use Excel to set up the timecodes, etc, but personally I find that too distracting, preferring to work with STL Edit when I need to add subs.
    One thing is almost universally agreed upon in here - create the subs outside of DVDSP and import them in, since if you need to move, alter or otherwise change them it is a lot easier from within a text file than from within DVDSP.

  • How can I get a cursor position?

    Hi Everyone!
    In my TextArea, there is a blinking cursor.
    How can I get the cursor position not the mouse position.
    Thanks,

    Thanks JefferyGong!
    That is selection index number, not the coordinate point.
    I want to know point position.
    Gyi

  • How to copy the  positions and their relationships of one org.unit to other

    f there about 20 organization units among which 6 org.units have same positions and same relationships ,i know that we can create one org.units and their relationships among 6 similar org.units and then copy the same position and relationships to other 5 org.units as well instead of individually creating positions and assigning relationships to them  which results in wasting a quality time.but i dont know how to copy it? so please help me by informing me in details how to copy the positions n their relationships to other org units.

    Hi.
    This may sound like a bit of a pain in the *** but why not save the channel strip settings into your own folder then that way you can open them up in other songs and you have some channel strips to try out when you cant find anything else to fit. Plus its fun to open up lots of different audio onto the tracks and see what the effects sound like, Brian Eno style.....
    Hope this helps

  • How do I keep my page from zooming in and out and my cursor moves all on it's own

    I have a mac pro and my page keeps zooming in and out all on it's own and my cursor just moves around with out me doing it, How do I keep my computer as it's suppose to be normal

    Mac Pro or MacBook Pro,What OSX,  if you have a track pad (MBP) check system preferences track pad zoom&scroll, or zoom options functions (slightly different depending which OSX) if a mouse holding control while using wheel will affect the screen, as well as swiping on a track pad.
    Also see the following:
    http://support.apple.com/kb/TS1449

  • How to do SelectAll and DeSelectAll

    Hi all,
              wat should be the cardinality and selection of Context node which is binded with Model data of a Table while implementing SelectAll and DeSelectAll buttons
    the code i used is
    int n = wdContext.nodeTableData().size();
    for( int i = 0; i<n; i++)
       wdContext.nodeTableData().setSelected(i, true);
    But it is giving error as Selection of nodeTableData does not allow Multiple Selection
    or i have to add one more column and context value to my table and implement the following code
    For SelectAll
    IPrivate<View>.I<Table>Node tNode=wdContext.node<Table>().;
    for(int i=0;i<tNodesize();i++)
    tNode.get><Table>ElementAt(i).setCheck(true);
    Can any one please let me know how to solve this problem
    Regards
    Padma N

    The cardinality need to be 0-n or 1 - n, other wise you cannot select the records  from node, if your bingding with a model node, then you need to set in the cardinality for the satrting node.
    otherwise you need to create your value node,
    Cheers.
    Apparao

  • After I click system preferences to change my screensaver, it will say loading images and the cursor will be loading. How do i fix this ?

    After I click system preferences to change my screensaver, it will say loading images and the cursor will be loading. How do i fix this to be able to change my screensaver and not have my computer do this?

    Try system preferences>desktop,click desktop tab. Click the Apple folders, iPhoto, or folders. Click the pic you want on the icon, it should put the pic as your wallpaper. You can change the picture if you change picture if you click it and the time.  Unless I don't understand your question.  ATB

  • How do I stop my cursor from selecting things on the page? It shows up like I want to type something and when I press the down key it goes through all the words like its a word document.

    How do I stop my cursor from selecting things on the page? It shows up like I want to type something and when I press the down key it goes through all the words like its a word document.
    == This happened ==
    Every time Firefox opened
    == June 27, 2010

    You have '''caret browsing''' enabled - that preference appears as set in your Troubleshooting Information.
    http://kb.mozillazine.org/Accessibility.browsewithcaret
    Hit the '''F7''' key to disable '''''caret browsing'''''.

Maybe you are looking for