To control the cursor in JTextField

Hi,
I am Meena.
To control my jTextField(accept only 10 charecters),Now I am using InputVerifier.
If I enter less than 10 charecters,I can go to next TextField.
If I enter more than 10 charecters I cannot go to next TextField.
I did this by Verify() method.
But what my need is myTextField should not accept more than 10 charectors,If I try to enter 11th charecter the cursor should not move.
Is it possible?
will you please help me?.
Thank you so much.
Meena.

But what my need is myTextField should not accept more than 10
charectors,If I try to enter 11th charecter the cursor should not move.here's a simple example, setting the textfield's document.
DocumentFilter is the newer way,
but I'm comfortable with just Document (old dog, new tricks)
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
class Testing extends JFrame
  public Testing()
    setLocation(400,300);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JTextField tf = new JTextField(new CharacterLimiter(10),"",10);
    JPanel p = new JPanel();
    p.add(tf);
    getContentPane().add(p);
    pack();
  public static void main(String[] args){new Testing().setVisible(true);}
class CharacterLimiter extends PlainDocument
  int maxChar = -1;
  public CharacterLimiter(int len){maxChar = len;}
  public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
    if (str != null && maxChar > 0 && this.getLength() + str.length() > maxChar)
      java.awt.Toolkit.getDefaultToolkit().beep();
      return;
    super.insertString(offs, str, a);
}

Similar Messages

  • How to control the cursor position on a text item..

    Hello,
    How can we control the cursor position programmatically on a text item.
    i.e. how do we move the cursor to home or end of the text item.
    TIA,
    Hiten

    If you have an access to metalink.oracle.com, take a look at notes:
    Note 61656.1 (V45) HIGHLIGHTING A REGION OF TEXT
    Note 131028.1 Default Highlighting in Forms (Client Server)
    and threads from metalink forum:
    531481.996 "Select_All not working in 6.0.8.25.2", 153092.995 "Text item cursor position"

  • Controling the cursor position

    Hi all,
    I have two x, and y signal outputs from a dll module and I plan to use them to control the cursor position. One problem I'm facing is that my signals are variable enough to cause the cursor to vibrate in stationary setting. So, I use hysterysis (putting threshold) to eliminate these fluctuations but the drawback is that keeping the treshold high enough to eliminate the fluctuations keeps me from getting a nice, smooth movement when the speed of movement (rate of x and y changing) is low. Any ideas or suggestions will be appreciated.
    p.s. I am using "SetCursorPos".dll as you might have already guessed.
    Thank you,
    Elnaz

    The formula for an exponential filter of degree D is the following:
    New Average = (New Value + (D-1)*Old Average)/D
    I usually add a special case for startup so that D is never greater than the number of points. 
    As I said, it is a low-pass filter, much like using a running average.  I usually like it because the state is simply a single value (Old Average) instead of the array of values you have to keep around to do a running average.
    As to the new question of separating high-frequency noise from your high-frequency signal, that is a bit more complicated (obviously).  You should take a power spectrum of the noise to see if there is a characteristic feature you can use (cutoff frequency, strong peaks).

  • Is it possible to control the cursor of a XY-graph via Keyboard and read the y value of the curser x-position?

    I have following problem when I control the cursor via an attribute note, it is neccersary to free the cursor, but then it is not possible to read the y-Value of the cursor position. I want to control the cursor via keyboard and buttons, but with the funtionality of attribute setting "cursor fixed to plot".

    You know the X position so just read the Y value by reading it straight from the Y array instead of from a property node...
    Alternatively unlock the cursor if the position control has changed...and lock it again if it is constant for n milliseconds; to produce the Y value from the Y property.
    MTO

  • How to control the cursor location(without mouse control)??

    Hi,
    I am now developing a swing application which need to use a thread to change the cursor location.
    Can the cursor location be controlled by a thread?
    thank

    can be done using class Robot

  • Can I control the cursor position

    I'd like to confine the cursors position to a grid when it's within a particular panel. I tried public void mouseMoved(MouseEvent e)
    int x = (int) (GRIDSIZE*java.lang.Math.round(e.getX()/(1.0*GRIDSIZE)));
    int y = (int) (GRIDSIZE*java.lang.Math.round(e.getY()/(1.0*GRIDSIZE)));
    e.translatePoint(x,y);
    } But that didn't work. Can it be done?

    I'm not exactly sure what you want to be done, but, if you want to control the mouse position, you can create a Robot object (check the class in the java docs) and use robot.mouseMove(mouseX,mouseY) where mouseX and mouseY are integers. THIS ONLY WORKS IN APPLICATIONS THOUGH. its too powerful to be able to control a persons mouse, (and keyboard is controllable too with Robot), you can imageine what a person could do lol.. Anyway, you could repeatedly check if the mouse position is on the grid, and if it isn't, use robot.mouseMove, to place it onto the grid.

  • How to control the cursor position in the Table control in Module pool

    Hi,
    Can any body tell me how to change the cursor positon from last field of the first record to the
    first field of the second record , when user presses enter in the last field in the module pool
    programming.
    Thanks

    Hi,
    Please avoid posting duplicate posts.
    Re: how to get the cursor position from screen in module pool program
    Nag

  • My magic mouse no longer controls the cursor. new batteries don't fix it. like it's died.

    My magic mouse used with G5 has apparently died all of a sudden. Doesn't move the cursor.Fresh batteries don't fix. 
    Is it really dead? Can it be revived?

    Try resetting the SMC and PRAM.  If that does not work, it is probably gone.
    Barry

  • Placing the cursor in JTextField

    When the form gets loaded i want to place the cursor in a particular JTextBox of the form. How do i do this?
    thanks in advance.

    From the API
    grabFocus() - This method is intended for use by focus implementations. Client code should not use this method; instead, it should use requestFocus().
    requestFocus() - Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible.
    requestFocusInWindow() - The focus behavior of this method can be implemented uniformly across platforms, and thus developers are strongly encouraged to use this method over requestFocus when possible. Code which relies on requestFocus may exhibit different focus behavior on different platforms

  • Using version 4 or 5 will not control the cursor

    When in version 3.xx if I go to delete an item and click on 'delete' the cursor will then move to a box in a new window which reads 'Yes' or 'Confirm'.
    This second step does not occur in versions 4 or 5

    It wont as it comes with 10.5.5, you need to install the combo http://www.apple.com/downloads/macosx/apple/macosx_updates/macosx1055comboupdate .html

  • HT4285 my trackpad shows up as a connected device but i cannot control the cursor

    my trackpad shows up as a connected bluetooth device but i cannot control the cursor

    Reset your computer's PRAM
    http://docs.info.apple.com/article.html?path=Mac/10.7/en/mh26871.html

  • I can not control my cursor with the trackpad.  It moves randomly. It began after an Angry Birds update.  Anyone else have this problem?

    I have a late 2011 OS X Lion 10.7.4 that is only 6 months old.  For the first 4 months I had no problems, but then about 6 weeks ago I downloaded an Angry Birds update from the Apple App Store, and my problems began.  When playing Angry Birds the the new Angry Birds update for the first time the cursor began to jump around, moving on it's own as if someone else was controlling it.  After a few moments I became obvious I could not control the cursor with the trackpad. When I placed the tip of my finger gently in the center of the trackpad to try to hold the cursor still it becan switching from the game (desktop) to launchpad and mission control.  I then put the computer down so I was not even touching it, walked several feet away and the cursor still moved on it's own.
    I've done a lot of research over the last few weeks on related articles and realized this is a common problem with numerous different causes: PRAM settings,
    screen sharing, remote settings, having fingers accidently touch edges of trackpad, writst resting too close to trackpad, swollen battery, etc. and I don't think it's due to any of those issues.
    The problem came out of nowhere.  My computer stays at home, and is not used by anyone else.  At first it was just Angry Birds, but now it can happen at any time.  Sometimes hours or days go by when this does not happen, sometimes it happens so much I can't use the computer at all.  It can get so bad that I won't be able to click out of whatever I'm doing on my desktop, and I'll have to shut it down by holding the power button. 
    Has anyone else had this issue after updating Angry Birds?

    try a new/fresh apple brand cable and make sure it is the only usb cable in use. this worked for me, i noticed i had no problem with a lighting cable. i did a restore from scratch and from backup and it did not help me...and if you cant sync than you wont be able to get anything but apps back after the restore

  • Dispaying a waveform graph with control of the cursor in the document.

    I would like to be able to control the cursor when I save my waveform graph in html. I'm currently saving the graph through the report vi's

    I am not sure I understand your question. Do you want to simply control where the cursor is on the picture you are appending to the html report. If so then when you use the Append Control Image to Report VI it basically takes a snap shot at that moment and displays it. Therefore you just need to place the cursor where you wnat it before you add the image.
    To programttically control the cursor you will need to use property nodes of the Waveform Graph. A good start would be the property cursor>>cursor position>>all elements.

  • Position the cursor in a JTextField

    Hi !
    I have an App with 10 JTextFields and I want to position the cursor from JTextField No.2 to JTextField No.8
    Is there a possibility to tell the program that the cursor have to go to an other Component ?
    Thank you. Wolfgang (KLD)

    You'll want to check out
    "grabFocus" in javax.swing.JComponent
    For some additional niceties you may want to check out
    "setFocusAccelerator" in javax.swing.text.JTextComponent
    It provides automated ways to jump around components.
    H

  • Keyboard control of the cursor?

    Is there any to control the cursor with the keypad?  Some control key's I haven't found?  A keyboard based "cut and paste" system?

    There are no cursor/arrow keys on the pop-up keyboard on the iPad's screen as there is only an insertion point on the screen and not a cursor. If you want to move the insertion point, or use cut/copy and paste then you use your finger on the screen - pressing and holding an area of text should bring up a magnifying glass so that you can then drag the insertion point to where you want it. For cut/copy and paste (from the manual) :
    Select text: Tap the insertion point to display the selection buttons. Tap Select to select the adjacent word, or tap Select All to select all text. You can also double-tap a word to select it. In read-only documents such as webpages, touch and hold a word to select it.
    Drag the grab points to select more or less text.
    Cut or copy text: Select text, then tap Cut or Copy.
    Paste text: Tap the insertion point, then tap Paste to insert the last text that you cut or copied. Or, select text, then tap Paste to replace the text.
    Undo the last edit: Shake iPad, or tap undo on the keyboard.

Maybe you are looking for

  • What are the settings for datasource and infopackage for flat file loading

    hI Im trying to load the data from flat file to DSO . can anyone tel me what are the settings for datasource and infopackage for flat file loading . pls let me know regards kumar

  • Photoshop edited images move to iPhoto & iWeb

    I plan to redesign my web site and publish in iWeb. Previously, my web site was developed with FrontPage and hosted on an Earthlink server. My photo images were edited in Photoshop. I assume I will need to import my photos into iPhoto before designin

  • What classes should I use to send/receive bytes inmediately?

    What classes should I use to send/receive bytes inmediately? I mean, without using any buffers or whatever (I will implement this on my app), just the faster method. Is InputStream/OutputStream the lowest level choice? Thanks!

  • How to initialize an adf component before a page loads

    Hi all I use JDeveloper 11.1.2.2.0 I have two pages: first page has a link to a second page <af:document title="first.jspx" id="d1">   <af:form id="f1">     <af:commandLink text="Page 2" id="cl1" action="goToSecondPage" actionListener="#{Bean.handleL

  • Installation of java 1.3

    For a particular website I am supposed to install java 1.3.02. Upon installation I am promptly booted from said site and an error message comes up declaring exception_illegal_instruction. I have done numerous things all to no avail...any suggestions