How do u make a text field for int only

Hi I wanted to make the text Field int only
I.e
int temp = 0;
temp = testField.getText();
Thanks in advance

Rarna, I think this is what you are asking. This is a bare-bones TextField that only accepts keys that are numeric. I found that the left and right arrows still work. Backspace and delete do not so you would have to add additional case statements and code to handle these if you want to support them. I added a main method to try this out.
import java.awt.*;
import java.awt.event.*;
public class NumericTextField extends TextField implements KeyListener {
   public NumericTextField() {
      super();
      this.initField();
   public NumericTextField(int columns) {
      super(columns);
      this.initField();
   public NumericTextField(String text) {
      super(text);
      this.initField();
   public NumericTextField(String text,int columns) {
      super(text,columns);
      this.initField();
   private void initField() {
      setEditable(false);
      addKeyListener(this);
   public void keyPressed(KeyEvent e) {
      int key=e.getKeyCode();
      switch(key) {
         case KeyEvent.VK_0:
         case KeyEvent.VK_1:
         case KeyEvent.VK_2:
         case KeyEvent.VK_3:
         case KeyEvent.VK_4:
         case KeyEvent.VK_5:
         case KeyEvent.VK_6:
         case KeyEvent.VK_7:
         case KeyEvent.VK_8:
         case KeyEvent.VK_9:
            setText(getText()+e.getKeyChar());
   public void keyReleased(KeyEvent e) {;}
   public void keyTyped(KeyEvent e) {;}
   public static void main(String[] args) {
      Frame f=new Frame();
      NumericTextField ntf=new NumericTextField();
      f.add(ntf);
      f.pack();
      f.setVisible(true);

Similar Messages

  • How do I make my text field automatically upper case?

    How do I make my text field in a form automatically upper case?

    Use the following as the text field's custom Keystroke JavaScript (choose a Format type of Custom):
    // Keystroke script for text field
    event.change = event.change.toUpperCase();

  • How do I make multiple text bold, for example scene headings or character names?

    How do I make multiple text bold, for example scene headings or character names?

    You can do that by editing the template of the document.
    Open the document, go to Edit->Template. A dialog will launch which will have element types on the left and it's properties on the right.
    Select Scene Heading(or Character name) on the left. On the right, go to 'Text' tab and click on Bold checkbox.
    Press OK.
    Hope this helps.
    Cheers,
    Sunny

  • Acrobat Forms -- how do i make a text field opaque when typing

    I'm new to the Forms formatting, so bear with me. I'm trying to create a fillable form which has rules to fill in by hand. How can I create a text field box that will cover the rules behind it if someone chooses to type the info instead of handwriting. I found a script that almost works:
    if (event.value.toString().length > 0) {
    event.target.fillColor = color.white ;
    } else {
    event.target.fillColor = color.transparent ;
    The only problem with this is that the rules show while typing on top of them. The box turns opaque when a new entry is made in another field. Anyway to make the box opaque while they're typing ?

    Here's a link to a demo that I believe behaves as you want: https://workspaces.acrobat.com/?d=AG6oZ3bi3DYHokxDPeWN7A
    It is controlled by several scripts, so study them to see how it works.

  • How do I make a text field expand in depth so I can see it in print?

    I am totally new to making forms in Designer. So please bear with me.
    I created a simple form for teachers to use as an evaluation tool. A question is asked on the form, and the teachers have space to reply in the text field just below.
    The trouble is, I want the expanding field to actually "push" the content below it as the field increases in depth. That way, when users print the form for the record, their responses can be viewed in their entirety on the page.
    At the moment, the text fields expand with *scrollbars,* which allow multiple lines of text -- but when you print, you only see a few lines.
    How can I accomplish this?
    Thanks to everyone for your help. -- Barbara

    Hi Barbara,
    Basically, you do it by creating a dynamic form.
    WARNING: When you do this, other parts of your form may go wonkers if they're not set up carefully, so be sure and save a copy of the original first.
    --Be sure your form is saved as a dynamic PDF. Check to make sure the preview type is set for Interactive (File menu > Form Properties > Defaults > Preview Type)
    --Set the text field itself to "Expand to fit" (Layout palette, Height)
    --Wrap it in a subform set to "Flow Content" (Object palette, Type. Also check "Allow Page Breaks within Content" on the Object palette)
    --Set the main subform for the page it's on to "Flow Content" as well.
    You'll still see the scroll bars, but after you exit the field it will expand the way you want it to.
    You can read up on the two types of subforms in Designer Help.
    Let me know if that works for you.
    Ann

  • How can i make a text field expand

    I have over 7 paragraphs that im inserting into atext field (even if i had type)
    The expand textbox merely keeps going horizontally not vertically. How can i stop it going horizontally and go down the page and on the next page if it needs it.
    PLEASE PLEASE

    Hi,
    Try by checking expand to fit in height(it is present under layout palette of designer)and checl "allow multiple lines" under object palette and save the form as "dynamic pdf" and check.
    Regards,
    Sangeetha.

  • PLS HELP! How can I make editable text easier for user on iPad?

    Hi,
    I am having trouble allowing the risk elements text to be edited easily on ipad, can anynoe take a look at this project and ffe any solution?
    https://www.dropbox.com/s/7i2xu9n0pv8qqf2/RISKRADAR%20EDGE_fin.zip
    thanks@

    HI there, your current implementation seems pretty legit to me. I was able to edit the text prety easily the first time, but then when I try to edit the text again, I can't seem to select the text. Not sure if your drag behavior is overriding the input text.

  • How to make a text field exactly 3 chars wide?

    I have an telephone area code item text field in a form which only can be input 3 digits. How can I make this text field exactly 3 chars or digits wide?
    Appreciate!

    244805,
    What browser are you using?
    I just set up an item with Width & maxWidth of 3, and I cannot type more than 3 characters in it. I also changed Width to 1, and it still worked as I expected.
    As I alluded to in my prior post, the size is approximate - it all depends on the font size used.
    Thanks,
    - Scott -

  • How to make the text fields as mandatory (in 'notes and attachment' tab)?

    Hi,
    We have defined some Fixed Values for texts under IMG>SRM>SRM Server>Cross Application Basic Settings>Text Schema>Define Fixed Values for Texts, for a certain transaction type of RFx responses for a text schema.
    Because of this, the bidder can choose one of these fixed values for texts. This is perfectly working fine.
    Now the question is, we want to make the texts fields as mandatory. i.e. The bidder should not be able to submit the responses if certain texts are blank.
    Is there be any BadI for this?
    GH

    You can use BBP_DOC_CHECK_Badi for this field validation using a filter value RFx/Bid (I ont remember exact word).
    Regards,
    Jagadish.

  • How to retrieve the data in texts field for ME23N

    hai all,
    i need to do some coding for the item texts field for PO, which can be saw under ME23N. i need to retrieve the details in the text. but i have no idea how am i going to get the data from that field, which table is it under for PO?
    please advice. thanks

    Hi,
    the texts will be stored in STXH table..u need to pass the four values TDOBJECT
    TDNAME
    TDID
    TDSPRAS...U will get the text details
    Or
    use the FM 'READ_TEXT'.
    cehck the below links
    http://www.sap-basis-abap.com/sapac002.htm
    FM READ_TEXT
    reward if helpful.
    Regards,
    Nagaraj

  • How to make a text field smaller in size

    Can I make a text field smaller in size (not just the length
    but also the height) depending on the font size eg 10px. Whatever
    font size I seem to use the text field stays the same size.

    Can you give an explicit example of what you want? Are you
    referring to the
    font size that someone sets in the browser, or the size you
    set in the page?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "~Billy~" <[email protected]> wrote in
    message
    news:fa3oh4$67u$[email protected]..
    > Can I make a text field smaller in size (not just the
    length but also the
    > height) depending on the font size eg 10px. Whatever
    font size I seem to
    > use the text field stays the same size.

  • Does anyone know how I can create a text field in a pdf document that will multiply a total in another box?

    does anyone know how I can create a text field in a pdf document that will multiply a total in another box? I’m making an interactive pdf for an order form (attached), and I need to find a way for the “total quantity” number to multiply by 9 and total in the “Amount Due” box.

    Hey Gary,
    Have a look at this post: Re: horizontal scrolling similar to excel
    Andy's reply will show you how to make a table scroll horizontally, but it will be tough to accomplish it in some sort of easily replicable way. I am working on a JQuery extension that will help accomplish this, but I have had my time invested in another project at the moment.
    Good Luck,
    Tyson

  • How can I get the "text" field from the actionEvent.getSource() ?

    I have some sample code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.ArrayList;
    public class JFrameTester{
         public static void main( String[] args ) {
              JFrame f = new JFrame("JFrame");
              f.setSize( 500, 500 );
              ArrayList < JButton > buttonsArr = new ArrayList < JButton > ();
              buttonsArr.add( new JButton( "first" ) );
              buttonsArr.add( new JButton( "second" ) );
              buttonsArr.add( new JButton( "third" ) );
              MyListener myListener = new MyListener();
              ( (JButton) buttonsArr.get( 0 ) ).addActionListener( myListener );
              ( (JButton) buttonsArr.get( 1 ) ).addActionListener( myListener );
              ( (JButton) buttonsArr.get( 2 ) ).addActionListener( myListener );
              JPanel panel = new JPanel();
              panel.add( buttonsArr.get( 0 ) );
              panel.add( buttonsArr.get( 1 ) );
              panel.add( buttonsArr.get( 2 ) );
              f.getContentPane().add( BorderLayout.CENTER, panel );
              f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              f.setVisible( true );
         public static class MyListener  implements ActionListener{
              public MyListener() {}
              public void actionPerformed( ActionEvent e ) {
                   System.out.println( "hi!! " + e.getSource() );
                   // I need to know a title of the button (which was clicked)...
    }The output of the code is something like this:
    hi! javax.swing.JButton[,140,5,60x25,alignmentX=0.0,alignmentY=0.5,
    border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1ebcda2d,
    flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,
    disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,
    right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,
    rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=first,defaultCapable=true]
    I need this: "first" (from this part: "text=first" of the output above).
    Does anyone know how can I get the "text" field from the e.getSource() ?

    System.out.println( "hi!! " + ( (JButton) e.getSource() ).getText() );I think the problem is solved..If your need is to know the text of the button, yes.
    In a real-world application, no.
    In a RW application, a typical need is merely to know the "logical role" of the button (i.e., the button that validates the form, regardless of whether its text is "OK" or "Save", "Go",...). Text tends to vary much more than the structure of the UI over time.
    In this case you can get the source's name (+getName()+), which will be the name that you've set to the button at UI construction time. Or you can compare the source for equality with either button ( +if evt.getSource()==okButton) {...}+ ).
    All in all, I think the best solution is: don't use the same ActionListener for more than one action (+i.e.+ don't add the same ActionListener to all your buttons, which leads to a big if-then-else series in your actionPerformed() ).
    Eventually, if you're listening to a single button's actions, whose text change over time (e.g. "pause"/"resume" in a VCR bar), I still think it's a bad idea to rely on the text of the button - instead, this text corresponds to a logical state (resp. playing/paused), it is more maintainable to base your logic on the state - which is more resilient to the evolutions of the UI (e.g. if you happen to use 2 toggle buttons instead of one single play/pause button).

  • How can I make a bootable disk for Mountain Lion?

    How can I make a bootable disk for Mountain Lion?

    Make Your Own Mountain/Lion Installer
    1. After downloading Mountain/Lion you must first save the Install Mac OS X Mountain/Lion application. After Mountain/Lion downloads DO NOT click on the Install button. Go to your Applications folder and make a copy of the Mountain/Lion installer. Move the copy into your Downloads folder. Now you can click on the Install button. You must do this because the installer deletes itself automatically when it finishes installing.
    2. Get a USB flash drive that is at least 8 GBs. Prep this flash drive as follows:
    Open Disk Utility in your Utilities folder.
    After DU loads select your flash drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    Click on the Erase button. The format process can take up to an hour depending upon the flash drive size.
    3. Locate the saved Mountain/Lion installer in your Downloads folder. CTRL- or RIGHT-click on the installer and select Show Package Contents from the contextual menu. Double-click on the Contents folder to open it. Double-click on the SharedSupport folder. In this folder you will see a disc image named InstallESD.dmg.
    4. Plug in your freshly prepared USB flash drive. You are going to clone the content of the InstallESD.dmg disc image to the flash drive as follows:
    Double-click on the InstallESD.dmg file to mount it on your Desktop.
    Open Disk Utility.
    Select the USB flash drive from the left side list.
    Click on the Restore tab in the DU main window.
    Select the USB flash drive volume from the left side list and drag it to the Destination entry field.
    Drag the mounted disc icon from the Desktop into the Source entry field.
    Double-check you got it right, then click on the Restore button.
    When the clone is completed you have a fully bootable installer that you can use without having to re-download Mountain/Lion.
    Note: The term Mountain/Lion used above means Lion or Mountain Lion.

  • Make all text fields read only after signing form

    Hello,
    I have a live cycle form which needs to have all of the text fields set as read only after signing.
    The java script has been placed in the post sign event of a digital signature field.
    for(var i=0;i<this.numFields;i++) {
    var cNm = this.getNthFieldName(i);
    if (cNm.type = "text") this.getField(cNm).readonly = true;
    After signing the form the following console error is shown:
    this.getNthFieldName is not a function
    Can anyone please advise how to revise the script so that when the form is signed all of the text fields become ready only?
    Any assistance will be most appreciated.
    Thank you.

    You don't need any JavaScript to do this.
    In Designer you can setup the signature field in that way, that all fields will be locked after signing.
    Look here:
    http://forums.adobe.com/message/3121870?tstart=2

Maybe you are looking for