Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By JosAH

Thread: How to write a code for defining a maxlenght for a textfield ?!

  1. #1
    qwerty53's Avatar
    qwerty53 is offline Member
    Join Date
    Jul 2011
    Posts
    32
    Rep Power
    0

    Question How to write a code for defining a maxlenght for a textfield ?!

    i don't know how i can code it.. i'm advanced in C.. But this is really different. what is wrong with that code ?

    if(username.lenght() > 12 ) {
    JOptionPane.showMessageDialog(null, "error.msg");
    }

    and how to focus on that line ? is there any functions about this subject ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    Use a DocumentFilter or a JFormattedTextField.

    db

  3. #3
    qwerty53's Avatar
    qwerty53 is offline Member
    Join Date
    Jul 2011
    Posts
    32
    Rep Power
    0

    Default

    i'm just a beginner. Can you show me an example ? i don't know how to use them..

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,381
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by qwerty53 View Post
    i'm just a beginner. Can you show me an example ? i don't know how to use them..
    My old grandfather always told me "what you don't know you can learn". Read the API documentation and possbily some turorials and don't beg for an example because you wouldn't understand it if you don't know what you're doing and just a copy/paste action won't do you much good either.

    kind regards,

    Jos
    qwerty53 likes this.
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. What are you using to write your code?
    By CaptainMorgan in forum New To Java
    Replies: 990
    Last Post: 07-24-2014, 03:28 AM
  2. Help me re-write pseudo code?
    By csisdifficult in forum New To Java
    Replies: 15
    Last Post: 04-21-2011, 06:30 AM
  3. Write XML-Code to console with SAX
    By enne87 in forum XML
    Replies: 6
    Last Post: 11-21-2010, 01:43 AM
  4. how do i write this code?
    By Libertyman in forum New To Java
    Replies: 23
    Last Post: 06-22-2010, 12:43 PM
  5. How To Write Unmaintainable Code
    By tim in forum Forum Lobby
    Replies: 2
    Last Post: 02-07-2010, 09:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •