Please help: need to set max numer of characters in JFormattedTextField!!!

Hi there,
We use JFormattedTextFields, initializing them via the constructor JFormattedTextFields(Format), where we specify a DateFormat or Numberformat (allowing either integers or decimal numbers). This works fine, the problem now is that we need to specify a format to the JFormattedTextField that allows only for a fixed number of string characters.
Can this be done via the Format class?? Seems to be a complicated task to subclass the Format class, maybe one could use the MessageFormat class...
Please, answer if you know of some whay to do this using the Format class (would not want to change our JFormattedTextField/Format based framework).
Best regards,
AC

You can try something like this:
public class FormattedText extends myJTextField {
   int Max;
   public FormattedText(int Max) {
      super();
      this.Max=Max;
   protected Document createDefaultModel() {
      return new FormattedDocument();
   protected class FormattedDocument extends PlainDocument {
      public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
         int j;
         int i=getLength();
         String currentText=getText(0,i);
         String beforeOffset=currentText.substring(0,offs);
         String afterOffset=currentText.substring(offs,currentText.length());
         String proposedResult=beforeOffset+str+afterOffset;
         if (proposedResult.length()>Max) {
            if (str.length()==1) return;                         // input too long
            i=(int)(Max-i);
            if (i<1) return;                                   // nothing we can do
            str=str.substring(0,i);                              // take as many characters as we can (otherwise we end up with a blank)
         super.insertString(offs,str,a);
};o)
V.V.

Similar Messages

  • HT5631 how do I verify my apple id? I can't sign in to it in mail and I can't make a new one because it just will not process I'm trying to set up iCloud between iPad and iPhone and having ALOT of difficulty pleAse help need it done by later on today!!!!!

    how do I verify my apple id? I can't sign in to it in mail and I can't make a new one because it just will not process I'm trying to set up iCloud between iPad and iPhone and having ALOT of difficulty pleAse help need it done by later on today!!!!!

    In order to use your Apple ID to create an iCloud account, the primary email address associated with the ID must first be verified.  To do this, Apple will send a verification email to your account and you must respond to the email by clicking the Verify Now link.  Make sure you are check the spam/junk folder as well as the inbox.  If it isn't there, go to https://appleid.apple.com, click Manage your Apple ID, sign in, click on Name, ID and Email addresses on the left, then to the right click Resend under your Primary Email Address to resend the verification email.

  • HT1689 i have my daughters iphone 3, i want to use it as an i-pod, but it keeps receiving messages from some her friends is there a way to stop this from happening, please help, my phone is maxed out and would really like the storage for music, thanks

    i have my daughters iphone 3, i want to use it as an i-pod, but it keeps receiving messages from some her friends is there a way to stop this from happening, please help, my phone is maxed out and would really like the storage for music, thanks

    It sounds like it still has her information on it, so it might be efficient to navigate to Settings, then General, then Reset, then Erase All Content and Settings. You can then set up the phone again, using your information. This way the phone will be yours, officially, and her data and information will be removed.

  • Help needed in setting up Japanese Database

    Hi there,
    Help needed in setting up Japanese Database.
    I created database with UTF8 character set on Sun Solaris O/S.
    Oracle version 8.1.7.
    I am accessing the DB through SQL*Plus (Windows client).
    I downloaded the Japanese font on client side and also set the NLS_LANG environment variable to Japanese_Japan.UTF8. Still, I am not able to view Japanese characters. O/S on client side is Windows 2000 professional (English). Is O/S (client) need to be Japanese O/S? When I try to retrieve sysdate, its displaying in Japanese but not all characters in Japanese. Can anyone help me out how to set up the client and is there any parameters to be setup at server side? I also tried to insert japanese characters into table through client, but it displaying as "?????" characters. Any help in this regard is appreciated.
    Thanks in advance,
    -Shankar

    lol
    your program is working just fine.
    do you know what accept does? if not read below.
    serversocket.accept() is where java stops and waits for a (client)socket to connect to it.
    only after a socket has connected wil the program continue.
    try putting the accept() in its own little thread and let it wait there while your program continues in another thread

  • Please, help me to set up wireless Internet connection. M...

             Please, help me to set up wireless Internet connection. My router is WRT54GS. I able to get online when computer is wired direct to VPN internet cable.
    First, I can’t open password request screen on http://192.168.1.1. 
    Second, when "Setup wizard" runs step #6 (“Check the router’s status”), the program asks for the password. Default password “admin” is rejected by the program and I can’t install Linksys software. Just in case I already pressed reset switch on the back of the router but to no avail. 
    Third, I don’t find out my Ethernet Adapter Wireless Network Connection and correct router’s IP address using ipconfig/all command after connecting WRT54GS with my computer. Ethernet adapter: DHCP disabled, subnet mask 255.255.255.0, IP address 10.32.132.193, default gate 10.32.132.1.
    Tell me please: what’s the matter?

    Pensive wrote:
             Please, help me to set up wireless Internet connection. My router is WRT54GS. I able to get online when computer is wired direct to VPN internet cable.
    First, I can’t open password request screen on http://192.168.1.1. 
    Second, when "Setup wizard" runs step #6 (“Check the router’s status”), the program asks for the password. Default password “admin” is rejected by the program and I can’t install Linksys software. Just in case I already pressed reset switch on the back of the router but to no avail. 
    Third, I don’t find out my Ethernet Adapter Wireless Network Connection and correct router’s IP address using ipconfig/all command after connecting WRT54GS with my computer. Ethernet adapter: DHCP disabled, subnet mask 255.255.255.0, IP address 10.32.132.193, default gate 10.32.132.1.
    Tell me please: what’s the matter?
    hi pensive ,
     Seems interesting , first do this -  push the reset button on the back of router .
    push it till 30 seconds , unplug the power cable and plug in the power cable back in After completion of 30 seconds.
    then try to log into , 192.168.1.1 again . with the password "admin".
    see if it reply?
    Else -
    strt>cmd>ipconfig /all - post the result ?
    pe@c3
    Message Edited by meteor on 01-09-2008 05:58 AM
    ~~~Nobudy's Perfect , i try To Be So ! Each n every moment of maH LYF , AND I THINK dat wats make Me "Different" From others....~~~

  • Please help needed os x lion I wish to transfer photos from the iPhoto library to a album or folder then delete them from the Library but when I do this it also deletes them from the album ? how do I do this please.

    Please help needed os x lion I wish to transfer photos from the iPhoto library to a album or folder then delete them from the Library but when I do this it also deletes them from the album ? how do I do this please.

    Albums are not places to store photos, they're more like "labels" you can apply to photos to better organize them. A single image file can be in multiple albums... they are not copies, it's simply been labelled as being in all those albums. So what you're trying to do doesn't make sense, because it's based on incorrect assumptions.
    The iPhoto library will always show all photos that you have added to iPhoto.

  • Guys i need to get m itunes account unlocked its stopping mefor making in app purchases please help need to make a purchase within 30 minutes

    guys i need to get my itunes account unlocked its stopping mefor making in app purchases please help need to make a purchase within 30 minutes

    If you've tried to buy something and your've been charged for it (and it's not a temporary store holding charge) but haven't received it then try the 'report a problem' page to contact iTunes Support : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes support via this page : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Please help - Scrollable result set in sql server 2000

    Hi can some one please help me. I'm trying to create scrollable result set in sql server 2000, but i just can't get it to work. I've been trying to do this for the past 12 hours. I want to go home, but I can't till I get this going! please help!!! My crap code is as follows:
    package transact;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JInternalFrame;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class DummyFrame extends Dummy
    protected String name, surname;
    protected Connection conn;
    protected CallableStatement cstatement;
    public DummyFrame()
    createFrame();
    private void createFrame()
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    conn = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://server:1433;" +
    "user=user;password=pwd;DatabaseName=Northwind");
    catch (Exception e)
    e.getMessage();
    populateFields();
    menuAction();
    show();
    private void menuAction()
    btncontacts.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    getRecords();
    populateFields();
    btncontacts.setText("NEXT");
    btnkeywords.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    // transaction.getRecords();
    nextRecord();
    populateFields();
    btncontacts.setText("NEXT");
    protected void nextRecord()
    try
    // CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    cstatement.getMoreResults();
    catch (Exception e)
    e.getMessage();
    protected void getRecords()
    try
    CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    name = rs.getString("Firstname");
    rs.first();
    // call stored procedure
    catch (Exception e)
    e.getMessage();
    // populate the fields;
    private void populateFields()
    txtfirstname.setText(name);
    txtsurname.setText(surname);
    }

    ummm ok i think the logic in your code is kinda screwy...
    here is what your should be doing.
    create the gui.
    get the resultset...
    have code that looks like this for nextRecord...
    protected void displayNextRecord(){
      // we do not call next here because we already called it last time
      surname = rs.getString("Lastname");
      name = rs.getString("Firstname");
      populateFields();
      if(!rs.next(){
        btncontacts.setEnabled(false);// i'm not sure what btncontacts is but we want to disable next becuase there are no more records...
    // in your intitalization code you need to do this...
    // you old stuff ending with...
    ResultSet rs = cstatement.executeQuery();
    // the new stuff...
    if(rs.first()){
      displayNextRecord();
    }else{
      btncontacts.setEnabled(false);//the result set is empty
    }ok the real problem you are having is that you are trying to display one record at a time but you are scrolling
    through the entire result set using while(rs.next()... what you
    want to do is create the result set once and scroll through
    it one item at a time with your gui.
    the example method i have given displays the data from the current
    row in your gui. then it advances the result set forward one row if possible. this method assumes that the result set will always
    be positioned on a valid row thus the need for calling
    rs.first() before we originally call displayNextRecord()
    well i hope you find this helpful.

  • Hi please help! After setting up a new mail account my wifi button has greyed out. I've tried rebooting it ie turning off and on but no joy. I'm a complete technophobe and have no idea what to do next. I can receive emails but am unable to reply. HELP PLS

    Please can someone help a total technophobe?!!! I have recently set up a new mail account and since I've done that my wifi button has greyed out. Not sure what happened as I had help from my daughter. She doesn't think that she did anything wrong as has been an iPhone user since day one!! She's at work now so I'm totally lost. Please help. Many thanks.

    it's' an issue on 4S..... here same problem, even after restore the firmware.... wifi and bt are lost....

  • Help needed in setting up CVS / wincvs

    Please help me in configuring CVS / wincvs. Iam tryinf to install CVS and WINCVS both on my win2000 machine.
    I have done until here:
    1) downloaded cvs.tar.gz file and opened up the file at:
    C:\CVS\MyCvs\cvs-1.12.1
    2) downloaded "wincvs", opened the file at:
    C:\CVS\My-Win-Cvs\WinCvs120
    and then installed it here:
    C:\Program Files\GNU\WinCvs 1.2
    3) Created a folders called master for "repository" purpose and in here:
    C:\src\master
    4) Created a folder called for each of the projects for the purpose as "work" area.
    C:\CVS-Projects\Project1
    I will create Project2, Project3..... as i keep adding Projects. But for the time being ...i have only ONE project as Project1.
    5) Then opened up the WINCVS browser window and went to Admin > Preferences:
    a) Tab General looks something like:
    Enter the CVS Root::pserver:dhirubhai@localhost:c:/src/master
    Authentication:"passwd" file on the CVS server
    Use Versioncvs 1.10 (standard)
    b) 5th ...WinCvs tab is:
    HomeC:\CVS-Projects
    and the rest of the other tabs are set to default.
    Please Help as when i do:
    Admin > login .....i get this:
    cvs -q login
    (Logging in to dhirubhai@localhost)
    cvs [login aborted]: connect to localhost:2401 failed: Connection refused
    *****CVS exited normally with code 1*****
    Iam very confused. Please help !!!!!
    -dhir

    I think you must install this to have a cvs srver on
    your machine:
    http://www.cvsnt.org/wiki/
    from where did you get this "cvs.tar.gz" file and what
    is in it?I have downloaded the cvsNT version. started the service.
    This is the URL that iam following:
    http://w1.858.telia.com/~u85831169/InstallCVSNT.html
    But iam getting problem at step # 9. Adding CVS users
    This is what i did ....after opening up the command prompt.....
    NJRARWKS0AB5 = my computer name.
    Please read inline:
    C:\>set cvsroot=:ntserver:NJRARWKS0AB5:/TEST
    C:\>cvs passwd -a <my-user-id-to-login-to-my-machine>
    cvs [passwd aborted]: the :ntserver: access method is not installed on this syst
    em
    why am i getting error when iam setting the password ????
    -dhir

  • Please, Help NEED immediately, Radeon 9200 Ati on 23" hd cinema display??

    Hi you all expert, i definitely need some help here after searching through the site , i still couldn't find the solution. Currently i am operating an old G4 Mac 400 mhz , rage 128 pro, the salesman told me it will support the new 23" hd cinema flat panel display, which he fails me, and after checking up the system requirement the minimum should have been radeon 7500. Anyway, i am contemplating on purchasing a new ati 9200 radeon mac edition (within my budget) and would like to ask if it will support the new 23" hd display sitting in my living room. Please help, thanks a million!!!!!

    You should have no problem with this card running the 23'' Cinema. It will indeed

  • Please help - need to restore my iPhone

    When plugging my iPhone into computer for the first time, I accidentally restored my iPhone with my fiance's for the backup. I freaked out and unplugged it halfway through the restoration. Now I have half of his settings/apps/contact info. and half of mine. I lost a lot of important contacts and notes. Please help - how do I restore my phone back to MY settings?

    Ekk, if you told it to restore his backup it would more than likely replace your information with his... Since this is your first time syncing your phone it likely hadn't made a backup of your device. You can check by opening iTunes, go to "Edit", "Preferences", click the "Devices" tab and see what's in there for backups.
    If there is nothing in there for you phone, there isn't really many other options to get those contacts back unless they are still on your computer or old phone somewhere.
    Out of suggestions you can do a few things to prevent this happening in the future, like setting up a seperate user account in Mac OS X/ Windows and syncing there or setting up some kind of automated sync like Goggle sync http://www.google.com/support/mobile/bin/answer.py?answer=138740&topic=14252  or Apple iCloud which will come out later this year.
    Sorry to hear, hope you have another copy around.

  • Please help: unable to set preferences for planning from workspace.

    Hi Experts,
    unable to set preferences for planning from workspace.(file--->preferences----->planning), when doing this task prompts " An Error occured" preferences works fine with other components IR, FR, WEB ANALYSIS.problem is only with the planning.
    1) i restarted the workspace and planning services but even then the same issue.
    Please help me out on this issue.
    Thanks.

    Hi,
    Do you get the same problem if you access planning directly ? http://<planningmachine>:8300/HyperionPlanning/
    Just trying to understand if it related directly to planning and maybe you will get a different error message.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Help needed to set up centro w/yahoo mail

    I can see my email when I go thru the web however it's not showing new messages that I see online with the computer.
    Also, want to set up the yahoo with the mail smart button.
    Please help.
    thanks!
    Post relates to: Treo 600 (Sprint)

    I got my at&t yahoo mail to work on the centro.  Not sure if it's the same as just plain old yahoo mail, but maybe this will help you.  Now I'm able to simply click the little mail button on my centro and it takes me to my inbox.  This was NOT through versa mail as far as I know.  To access the versa mail I have to go to a different icon on my centro thats just called "mail".  While my little quick mail key actually takes me to the application on my centro called "e-mail".
    I set it up as follows......
    Create your mail account and name it accordingly.   Enter your e-mail address and password and select next.  For mail type:  POP  enter your username (which is your e-mail address again).
    my incoming mail server I simply took right off my home computer set-up I had.  For me it was pop.att.yahoo.com  while the outgoing mail server was smtp.att.yahoo.com
    Then click on the advanced settings option.
    For the incoming service I selected to use a secure connection and made sure my port number matched what I had loaded in my home computer.  Then I selected next and for the outgoing server I selected to use the SSL connection AND the use authentication selection.  The later will require you to again enter your username and password (email address and password).  And I once again made sure my port number matched my home e-mail setting.
    And that was it.  I was able to get it to work. 
    Maybe it will not be the identical things for you, but maybe this will help some.
    Message Edited by herculesmomma on 05-05-2009 01:37 PM

  • TS3276 Please help me with setting up the email.

    I have set up a new email.  The message states it cannot use the port 995.  Please help me with this.  Thank you

    E-mail provider and is the account IMAP or POP? What message says it can't use port 995?

Maybe you are looking for

  • Memory Error in iMovie

    I'm new to the mac and imovie, enjoying both, but have hit a problem in my first movie. When I try to add transitions to clips I am getting a message warning that there is not enough memory to complete the activity. I have closed and reopened the app

  • TLF background color nigthmare

    I have done this to test the background color style on tlf. The problem is that the background color does not take the whole textline height just the ascent + decent height ignoring the leading. I have attached an image of the current l&f and the des

  • How do i print out membership card

    there's use to be away to print out membership card for rewards, now i cant seem to do it. tired of giving them my phone number to look it up.

  • 5 Apple machines don't see each other with Bluetooth

    I was hoping to use my keyboard with my iPad in the garden today, but they didn't connect. To try and find out which machine is faulty I brought in all our Apple's with bluetooth: my iPad1, an iPad2, my iPhone 4, an iPhone 4S (all with the latest sof

  • MacBook Pro Won't Sleep on Reserve Battery Power

    Hello fellow mac-users and mac-geeks, My Macbook Pro 2007 (2.2 GHz, Santa Rosa) was recently repaired by apple. The logic board was replaced due to the Nvidia issue. (If you don't know what that is, take a look in Apple's support documents.) I then b