JTextField and character length

Hi everybody!!
Please tell me how can I set my JTextField so that an user can't enter more that certain numbers of characters.
Thanks in advance

Boys, that is hard. Not quite sure if there is an easier way. Here is my suggestion:
public class textfield extends JApplet implements ActionListener{
     String string;
     String string2;
     JTextField textField;
     public void init(){
            textField = new JTextField();
            textfield.addActionListener(this);
            add(textField);
     public void actionPerfomed(ActionEvent e);
            if(e.getSource == textField){
                 string = textField.getText();
                 //if the string is maximum amount of chars store it in another string.
                 if(string.getLength() == 4){
                     string2 = string;
                 //if the string is greater than the maximum amount of chars set the textFileds text with the string2
                 if(string.getText() > 4){
                     textField.setText(""+string2);
That should do it.  If you have any questions just ask.  I would appreciate any duke dollars.  :-)
Virum                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • [JS InDesign CS3] Style groups, begone! (or: How do I take paragraph and character styles out of style groups?)

    Sorry for this question (and my terrible English, by the way), I'm a javascript noob and I know when I've reached my limits.
    Well, I'm trying to take a set of paragraph and character styles out of the style groups they are placed in, in hundreds of InDesign documents (that cannot be treated as a book). As far as I've tried (thanks to the invaluable help of previous posts in this forum) I've been able to move a style into a group and change it's position inside the group, inside the root level or even between groups. But it doesn't matter how I try, I don't know which move reference should I try in case I want to take every style out of their style group and place them after their original group folder, at the [Root] style level .
    I have tried:
    var doc=app.activeDocument;
    var pGroups=doc.paragraphStyleGroups;
    for (i=pGroups.length-1; i>=0; i--){
         var pStylesInGroup=pGroups[i].paragraphStyles;
         for (j=pStylesInGroup.length-1; j>=0; j--){
    // Here I am, trying to move a style outside the folder that contains it, and failing miserably.
              pStylesInGroup[j].move (LocationOptions.after, pGroups[i]);
    It didn't work, the script sent an invalid parameter value in the reference field, so I cant use the group folder itself as reference.
    Tried other (obviously wrong) solutions, like use the first available style as reference. Therefore, my second script was
    var doc=app.activeDocument;
    var pStyles=doc.allParagraphStyles;
    var pGroups=doc.paragraphStyleGroups;
    for (i=pGroups.length-1; i>=0; i--){
         var pStylesInGroup=pGroups[i].paragraphStyles;
         for (j=pStylesInGroup.length-1; j>=0; j--){
    // Now I try placing the styles after the [Basic Paragraph], that is, the second paragraph style in the document style list
              pStylesInGroup[j].move (LocationOptions.after, pStyles[1]);
    It didn't work either, another invalid parameter in the reference field. Similar results with my other attempts (I even tried "[Root]" as literal with similar luck).
    So, my question is: Which command (or script, in case my whole approach is utterly wrong) should I use to achieve my goal?
    Thanks in advance to whoever decides to spend more than a minute thinking about my humble worries, and my apologies for shamelessly ripping some of your lines of code for my purposes.

    Okay, tried a few things and got really weird results!
    1. You can move a style around inside its group.
    2. You can move a style out of a group "to" another, but it will appear 'inside' that style. I got my test style as a sub-item of [Basic Paragraph], using index #1. With index #0 ([No Paragraph Style]) InDesign crashed.
    3. You can duplicate the style, but then you get a copy in the same group. Still no luck.
    4. Finally! What is the parent of a paragraph style?
    Document | Application | ParagraphStyleGroup
    "Application" is easy -- that's when you make a style global. So what's the difference between 'Document' and 'paragraphStyleGroup'? Simple -- well, when you finally get it...
    pStylesInGroup[j].move (LocationOptions.AT_END, doc);
    moves the style out of the group and to the end of the list in the document. I don't think it's possible to move it directly to a specific position into the main style list -- you first have to move it out of a group, then move it around in its own list.
    Fortunately, it returns its new position as a ParagraphStyle again, so if needed, you can use
    newStyle = pStylesInGroup[j].move (LocationOptions.AT_END, doc);
    newStyle.move (LocationOptions.AFTER, pStyles[1]);
    -- I didn't really try that out, but it should work.

  • JTextField and JPasswordField

    Hi!
    How do I limit the character number that can be inserted into a JtextField and JPasswordField.
    For examen is the Password can be mam 6 characters, how do I do from limit the input?
    Thanks

    The most common way to limit what is entered in a JTextField is to create your own document. See the following thread:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=414464
    Graeme

  • Querying CHAR columns with character length semantics unreliable

    Hi again,
    It appears that there is a bug in the JDBC drivers whereby it is highly unlikely that the values of CHAR columns that use character length semantics can be accurately queried using ResultSet.getString(). Instead, the drivers return the value padded with space (0x#20) characters out to a number of bytes equal to the number of characters multiplied by 4. The number of bytes varies depending on the number and size of any non-ascii characters stored in the column.
    For instance, if I have a CHAR(1) column, a value of 'a' will return 'a ' (4 characters/bytes are returned), a value of '\u00E0' will return '\u00E0 ' (3 characters / 4 bytes), and a value of '\uE000' will return '\uE000 ' (2 characters / 4 bytes).
    I'm currently using version 9.2.0.3 of the standalone drivers (ojdbc.jar) with JDK 1.4.1_04 on Redhat Linux 9, connecting to Oracle 9.2.0.2.0 running on Solaris.
    The following sample code can be used to demonstrate the problem (where the DDL at the top of the file must be executed first):
    import java.sql.*;
    import java.util.*;
    This sample generates another bug in the Oracle JDBC drivers where it is not
    possible to query the values of CHAR columns that use character length semantics
    and are NOT full of non-ascii characters. The inclusion of the VARCHAR2 column
    is just a control.
    CREATE TABLE TMP2
    TMP_ID NUMBER(10) NOT NULL PRIMARY KEY,
    TMP_CHAR CHAR(10 CHAR),
    TMP_VCHAR VARCHAR2(10 CHAR)
    public class ClsCharSelection
    private static String createString(char character, int length)
    char characters[] = new char[length];
    Arrays.fill(characters, character);
    return new String(characters);
    } // private static String createString(char, int)
    private static void insertRow(PreparedStatement ps,
    int key, char character)
    throws SQLException
    ps.setInt(1, key);
    ps.setString(2, createString(character, 10));
    ps.setString(3, createString(character, 10));
    ps.executeUpdate();
    } // private static String insertRow(PreparedStatement, int, char)
    private static void analyseResults(PreparedStatement ps, int key)
    throws SQLException
    ps.setInt(1, key);
    ResultSet results = ps.executeQuery();
    results.next();
    String tmpChar = results.getString(1);
    String tmpVChar = results.getString(2);
    System.out.println(key + ", " + tmpChar.length() + ", '" + tmpChar + "'");
    System.out.println(key + ", " + tmpVChar.length() + ", '" + tmpVChar + "'");
    results.close();
    } // private static void analyseResults(PreparedStatement, int)
    public static void main(String argv[])
    throws Exception
    Driver driver = (Driver)Class.forName(
    "oracle.jdbc.driver.OracleDriver").newInstance();
    DriverManager.registerDriver(driver);
    Connection connection = DriverManager.getConnection(
    argv[0], argv[1], argv[2]);
    PreparedStatement ps = null;
    try
    ps = connection.prepareStatement(
    "DELETE FROM tmp2");
    ps.executeUpdate();
    ps.close();
    ps = connection.prepareStatement(
    "INSERT INTO tmp2 ( tmp_id, tmp_char, tmp_vchar " +
    ") VALUES ( ?, ?, ? )");
    insertRow(ps, 1, 'a');
    insertRow(ps, 2, '\u00E0');
    insertRow(ps, 3, '\uE000');
    ps.close();
    ps = connection.prepareStatement(
    "SELECT tmp_char, tmp_vchar FROM tmp2 WHERE tmp_id = ?");
    analyseResults(ps, 1);
    analyseResults(ps, 2);
    analyseResults(ps, 3);
    ps.close();
    connection.commit();
    catch (SQLException e)
    e.printStackTrace();
    connection.close();
    } // public static void main(String[])
    } // public class ClsColumnInsertion

    FYI, this has been mentioned as early as November last year:
    String with length 1 became 4 when nls_lang_semantics=CHAR
    and was also brought up in Feburary:
    JDBC thin driver pads CHAR col to byte size when NLS_LENGTH_SEMANTICS=CHAR

  • JTextField [] and MouseEntered

    Hello
    I know this type of question has been asked in the forums before, but might is kind of different...i think.
    I have an array of JTextFields and i want each of there color to turn to GRAY when the mouse is on top of them.
    So if mouse is on top of TextField1 then only TextField1 turns GRAY.
    my Current mouseEntered() method is this
    public void mouseEntered(MouseEvent me)
                 for (int i=0; i < nasdaqTFs.length; i++){
                nasdaqTFs.setEditable(false);
              nasdaqTFs[i].setBackground(Color.GRAY);
    This, obviously, turns ALL the TextFields to GRAY when the cursor is in the Panel. So cursor can be anywhere and they all turn GRAY.
    So the question is...how do i find out when the Cursor is on the Specific TextField.

    Learning from earlier today This time i did write a Short Example of what i want done.
    Maybe this time i didnt do a bad job at it
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Listener extends JFrame implements MouseListener
         JTextField t;
         JTextField t1;
         public Listener ()
              super ("test");
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              t = new JTextField(4);
              c.add(t, BorderLayout.NORTH);
              t1 = new JTextField (4);
              c.add(t1, BorderLayout.SOUTH);
              addMouseListener(this);
              setVisible(true);
              setSize(300,300);
              MouseMotionListener don = new MouseMotionAdapter(){
              public void mouseEntered(MouseEvent me) {
                   System.out.println("Enterd)");
                 me.getComponent().setBackground(Color.GRAY);
              t.addMouseMotionListener(don);
              t1.addMouseMotionListener(don);
         public static void main (String args[])
              Listener l = new Listener ();
           public void mouseEntered(MouseEvent me)
             /*JTextField tf = (JTextField) me.getSource();
             tf.setBackground(Color.GREEN);*/
                me.getComponent().setBackground(Color.GREEN);
           public void mouseExited(MouseEvent me)
             /*JTextField tf = (JTextField) me.getSource();
             tf.setBackground(Color.white);*/
                me.getComponent().setBackground(Color.WHITE);
           public void mousePressed(MouseEvent me){}
           public void mouseReleased(MouseEvent me){}
           public void mouseClicked(MouseEvent me){}
    }This GUI wont change colors of TF's either. However when i move around the GUI i see somethin Green flickering!

  • Extend character length of an idoc segment

    Hello Gurus,
    Our client requires a longer character length for NAME2 and STRAS. SAP standard is that character length for this is 35. Is there a way to extend the length of these idoc segments? Thanks in advance.

    About which IDOC are you talking?
    And why do you need more characters?
    If you are talking about CREMAS vendor or DEBMAS customer,
    then you should consider the ADRMAS Idoc as well.
    Because addresses are stored in central address managment tables sind 4.6 release.
    CREMAS and DEBMAS do not support central address management.
    Please read OSS note 306275 and 384462 for migration of addresses

  • Problem of character length

    I have a question about the length of character. If i set the variable  (e.g. GG) of internal table and its character length is 1000.    <e.g. data:  gg(1000).>
    and put it into one of the columns of the report listing.
    but that column only can see part of it (from 0 to 128 characters only).
    So if i want to change to excel, then the latter part of this field is omitted... How can i retain all the characters when export to excel format.
    coz i don't want to miss any data from here.

    but all the fields is get from the table (in the program)....
    for example:
    itab-CLOSING = xxxx-xxxxx. (which contains more than 255 characters)
    (i've use strlen( itab-CLOSING ) to check the length, it's normal ), but
      wa-fieldname = 'CLOSING'.
      wa-reptext_ddic = 'Closing Date/Time'.
      append wa to fcat.
      clear wa.
    the column itab-closing just show in the screen for the first 128 characters only. so i can't still get the whole data when export to excel ...

  • Character length of an editable fields

    hi frnz,
       I have created an editable field in an ALV report.My client wants the character length of this editable field as 1000.I have made the data type as 'STRINGS' and length as '1000', but still in this editable field i am able to feed only upto character length of 128 not beyond this value.The text which my client wants to feed is of 950 characters. Could anyone give some solution for this
    Thanks
    Praveen

    Hi, i think you have to give intlen and outputlen in field catalog
    FIELDCAT-INTLEN = 1000.
    FIELDCAT-OUTPUTLEN = 1000.
    Please check the doc of field catalog
    [http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649a6f17411d2b486006094192fe3/content.htm]
    Regards,
    Ben

  • Character Length in the Alias Naming

    Is there a limitation to character length in the alias of a member name?

    Thanks, Was running into issues and thought this to be the case, just did not know the exact limitation!

  • Character Length restrictions in BW

    Dear BW Experts,
    We are getting data from an external source. We have a field whose length is more than 60. I am unable to bring this field in to BW since BW has the restriction of not more than 60 character length. I cannot split the field since it is like a comment field.
    Could you tell me if there are other ways of getting such data in to BW where the length is more than 60 say like 500 or 1000 in length.
    Thanks,
    Sai

    Hi Sai,
    As we all know maximum length of info object is 60.The only way to get the data more than 60 is create another info object and add this as attributes to the base info object and make this attributes as display attributes.
    check the below blog, you have clear explanation
    /people/sap.user72/blog/2006/05/27/long-texts-in-sap-bw-modeling
    Regards,
    Venkatesh

  • Editor maximum character length allowance

    Greedings,
    Is it possible to make an editor to have a max character length? and how is that possible?
    Thank you

    1. 256
    2. The best online source of this information is probably the IBM LDAP schema reference site:
    http://www-1.ibm.com/servers/eserver/iseries/ldap/schema/
    Just click on attribute types on the left hand menu then scroll down to the attribute you wish to find out information about. You will notice OC information is on this site as well ...
    HTH,
    -Chris Larivee

  • ID character length - 16 or 20?

    What is the max character length of dimension IDs in BPC for NW? I thought it was 16 initially but now apparently is 20? According to an SAP doc:
    "Dimension field names may ONLY be max of 16 characters instead of 20"
    I understand property values can be up to 60 or greater. But, what about the the value of an ID? Does the above mean IDs can only be 16?

    Hi John,
    According to Scott from SAP, ID can be 20 characters.
    Ba
    Here is message from page 5 of below thread:
    BPC NW - Questions on How to Automate Master Data Loads
    Scott Cairncross      
    Posts: 272
    Registered: 1/5/05
    Forum Points: 548 
       Re: BPC NW - Questions on How to Automate Master Data Loads
    Posted: Jan 21, 2010 10:17 AM    in response to: Dries Paesmans           Reply 
    MDA - 20100121.zip (126.5 file.size.kilobyte) 
    Hi Dries,
    Velavan and I have been meaning to publish a new guide for sometime however we have not gotten the time to update everything. I am attaching a transport with the latest and greatest updates here to the forum for your and the rest of the communities benefit.
    There are some things to watch out for. Specifically if you are using scenario 1 of the guide and you are trying to load from an infoObject into a BPC Dimension where the infoObjects technical length is greater than 20 (the maximum length for a BPC Dimension) it automatically generates a hash key for the ID value that is 20 characters in length. This is not the behavior when running scenario 2.
    I hope this update helps.
    Cheers, Scott

  • Increasing character length

    Hi Experts,
                     I want to increase the character length of column in MS SQL Server 2005. How to modify the length of character.

    Hi Shailesh......
    You can modify the character length of UDF from Tools> Customization Tools> User Defined Management
    Select the UDF and press Update button and increase character length. Here also you can increase length and can not decrease it......
    Regards,
    Rahul

  • Character length semantics

    Hi,
    in 10g R2 how to enable Character length semantics ?
    Thank you.

    You cannot just enable character length semantics.
    The following link would be helpful.
    You need to export schema and import schema after setting the parameter
    NLS_LENGTH_SEMANTICS=CHAR
    [Character semantics |http://www.oracle.com/technology/oramag/oracle/03-mar/o23sql.html]

  • Logical and Physical Length in Datastore

    I would like to know the differences between logical length and physical length in datastore. Can anyone teach best practices to use them properly?

    Thank you Bouch,
    So usually is it required to set "logical length + 2" for physical length?
    Also, can you show exapmles for sign and dot, which to be added on each columns?
    Regards,

Maybe you are looking for

  • [SOLVED] Gnome & Firefox: Fonts are too small

    Hi, I am really used to using firefox in Windows XP where fonts are readable out-of-the-box. By this I mean I didn't have to fiddle with firefox when I installed it, the fonts looked great. Now that I'm using Gnome, I see that firefox's fonts are rea

  • Problem updating 8520 4.6 to 5.0

    currently i'm using 4.6 system software...  i 've previously updated my blackberry to 5.0 but for some technical issues , i downgraded it to 4.6... now i want to update it to 5.0 but as i double click loader.exe( vendor.xml deleted) , it starts but w

  • Configuration guide on Solution Manager Service Desk Scenario

    Hi all, I have just setup a Solution Manager 3.2 system and have followed the configuration guide, SP9.pdf which directs me to use SPRO to configure it. However, after going thru the SPRO, it doesn't gives me specific steps to setup the Service Desk

  • Picture uopload  using BSP

    Hello Everyone, Can any one help me out with this problem please. I have developed a BSP Application for the Picture upload using the code in the Blog /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents But I am not ge

  • ASA-SSM-10 7.0(5)E4 Error

    Hello, I have a strange error on my IPS, and can't find reason. Analysis Engine is Busy Processing Stage 3 of 97 at Step 0 of 1 Messages, like this one, in the category - ct to sensorApp timed out - were logged 1 times in the last 0 seconds.  name=er