Autocomplete Date in a textfield

How can I achieve autocompletion of dates in a textfield. If somebody inserts say 12 the backslash character automatically appears "/". Can somebody helped me out.

Hello,
you have to override document's insertString or in a custom textfield override createDefaultModel and return a new PlainDocument with custom insertString:package temp;
import javax.swing.*;
import javax.swing.text.*;
class Temp extends JFrame
     Temp()
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          initContentPane();
          pack();
          setLocationRelativeTo(null);
          setVisible(true);
     private void initContentPane()
          SeperatorField field = new SeperatorField(10);
          getContentPane().add(field);
     class SeperatorField extends JTextField
          SeperatorField()
               super();
          SeperatorField(int length)
               super(length);
          protected Document createDefaultModel()
               return new PlainDocument()
                    public void insertString(int offs, String str, AttributeSet a)
                         throws BadLocationException
                         if (str == null)
                              return;
                         int length = this.getLength()+str.length();System.out.println(length);
                         if(length ==2 || length == 5)
                              str=str.concat("/");
                         if(length>10)
                              return;
                         super.insertString(offs, str, a);
     public static void main(String[] args)
          new Temp();
}you can check for numbers the same way etc.
regards,
Tim

Similar Messages

  • How to recover the autocomplete data from a Time Machine backup?

    How to recover the Safari 5.1.7 autocomplete data from a Time Machine backup on Mac OS X 10.6.8 (Snow Leopard)?
    To solve other issues (Safari crashing sometimes when saving web pages), I selected:
    Safari - Empty Cache
    Safari - Reset Safari - Selected ALL - Reset
    I could later on recover some Safari autofill data restoring
    HD/Users/~/Library/Cookies/Cookies.plist
    HD/Users/~/Library/Safari/Form Values
    HD/Users/~/Library/Safari/History.plist
    but other autocomplete data is missing, including the one when filling web form search fields in web pages, for instance, and also some username and password login data on some web sites.
    How to restore all such data from the Time Machine Backup?
    Thanks!

    I also recovered:
    HD//Users/~/Library/Keychains/login.keychain
    What else should I recover?

  • How to display today's date in a textfield?

    Hi all,
    I have a textfield and it is a page item P18_DOJ.By defalut I want to display today's date in that textfield and it is should be readonly.How do i do that?

    Put "Select sysdate from dual;" as source type SQL Query and "readonly" in the HTML Form Element Attributes field.

  • How to compare Date in the TextField or DateTime with Date/Time field?

    Hi All,
    I am facing an issue with respect Date comparinson. I tried to look into entire discussions but failed to get the answer.
    My issue is: I wanted to comparet Date/time field value with Date value which is in TextField.
    The functionality of my form is:
    I have dropdown list which lists the registered customer ids binded to XML Datasource. On selection of the customer id from the dropdown I am displaying customer registration date in the TextField or say Date/Time field as below code in dropdown change event.
    RegistrationDetails.PurchaseEntry.txtRegDate.rawValue = regDataNode.CREATION_DATE.value; (this is TextField control)
    In form I have an Date/Time field in which use will select the date of item purchase. In the validation part I want to make sure that, the purchase date selected in Date/Time field must be greater than the Customer Registraiton Date. I able to compare if the customer selects the date from two different Date/Time fields. But how to compare the dates which one is in Date/Time field and Date is in TextField?
    I have tried using Num2Date and Date2Num with "YYYY-MM-DD"  format to compare but not succeed!
    Can you guys help me in this? Thanks in advance
    Regards.

    Hi,
    Yes, I am able to display the date which I have assigned to the text box. In the message box it show the value as '31/05/2009', since in this format i am assigining the date in the text box.
    Here is the code which I am assigning the value:
    RegistrationDetails.PurchaseEntry.txtRegDate.rawValue = regDataNode.CREATION_DATE.value;
    Do I need to change the format while assigning value in text box?
    You have told that, you have attached your test form, nothing is the reply. Can you repost the file?
    Regards.

  • Date in a textfield

    Does anybody know the code to put the date in a textfield?
    I'm new in this.

    Your code is not good. It's not :
    JTextField datum2= new JTextField(10);
    Calendar date = GregorianCalendar.getInstance(TimeZone.getDefault());
    datum2.setText(date.get(Calendar.DAY_OF_MONTH)+"/"+date.get((Calendar.MONTH)+1)+"/"+date.get(Calendar.YEAR));
    but
    JTextField datum2= new JTextField(10);
    Calendar date = GregorianCalendar.getInstance(TimeZone.getDefault());
    datum2.setText(date.get(Calendar.DAY_OF_MONTH)+"/"+(date.get(Calendar.MONTH)+1)+"/"+date.get(Calendar.YEAR));

  • Conversion from date to number & display a date in a textfield

    I Have 2 issues
    The first one:
    I need to extract the hour from a date variable.
    This is the code I already have:
    NUM_TOT := NUM_TEL + to_number('PROGRAMMINGS1.PRG_START','hh24');
    NUM_TOT & NUM_TEL are number variables,
    PROGRAMMINGS1.PRG_START is a Textfiel with a dateformat. There can only be an houre like 24:59:00 entered.
    So in this example I just want the houre and convert it to a number.
    The second:
    I want to make a date from a few numbers & then display it in a texfield.
    This is the code I already have:
    VAR_DATE := NUM_TEL || ':' || NUM_LENGTH || ':00';
    :PROGRAMMINGS.PRG_END := to_date(VAR_DATE,'hh24:mi:ss');
    Between the 2 lines of code i places a message(VAR_DATE) for testing.
    When the program display VAR_DATE then i can see the good date at the bottom of the screen.
    But when I place my variable in the textfield it looks like: 00:00:00. What am I doing wrong?
    Who can help me.
    With regards
    Stefanie

    Verdi wrote:
    Problem: During the conversion (both implicit and explicit conversion with a format mask) I lose the "00" hours and "00" minutes and receive something like this: "10-JAN-13 *12*.00.00.000000000 AM".I don't think you are necessarily losing any information whatsoever. It's probably more of a function of your NLS_TIMESTAMP_FORMAT and NLS_DATE_FORMAT. For example your NLS_DATE_FORMAT could be setup by default for a HH24 (24 hour time) which would report midnight as "00" hours. However, it looks like your NLS_TIMESTAMP_FORMAT is setup with a "HH" format with a meridian indicator which means 12 hours time.
    Your comparisons should be using date/timestamp data types anyways so as long as the input value is converted properly into a date type this shouldn't matter anyways.
    You can see what is actually stored by using the DUMP function:
    SQL> SELECT  DUMP(TO_TIMESTAMP(TO_CHAR(TRUNC(SYSDATE,'DD'),'MM/DD/YYYY HH:MI:SS AM'))) AS TSTAMP
      2  ,       DUMP(TRUNC(SYSDATE,'DD')) AS DT
      3  FROM DUAL
      4  /
    TSTAMP                                                                      DT
    Typ=187 Len=20: 218,7,1,13,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0                  Typ=13 Len=8: 218,7,1,13,0,0,0,0As you can see the TSTAMP and DT store nearly the same values (218,7,1,13), but the TSTAMP has more precision because of fractional seconds.
    HTH!
    Edited by: Centinul on Jan 13, 2010 7:23 AM

  • Adobe Interactive Forms - Web Dynpro: itab data not in textfield layout

    Hi,
    out of a web dynpro application i'm generating a pdf document which is filled with data out of an internal table. This data is displayed with a name and following the itab value. But it looks like the value is displayed in a textfield. I want the value to be displayed like a standard text.
    How can I realitze this?
    Thanks in advance,
    Tan

    Hi Tan,
    What do you mean by standard text..?
    is that mean you want to display the content as a label (static text field..?) if so there are 2 approaches.
    1) drag and drop the field from data view onto form and change the visual properties of the field.
    2) Have a static text on the form right click in it, select floating field option in context menu, a field is generated do data binding for this field.
    if even my understanding of your requirement is wrong provide more info on the UI presentation you are looking for ..
    Regards,
    Sai Krishna.

  • Find the data in the TextField which is visible

    Requirement
    There is JTextField which has certain String say "ABCDEFGHIJ" and the textfield is small and could only display "ABC" and other data is in the JTextField but scrolled out
    I have another JTextField beneath it and so I want teh remaining data should be shown there
    The reason behind this is
    I have made a Display Screen in which there r 2 TextFields for a single Data which is going to be filled up automatically and Can't make one because the Form which is to be printed has to be like that
    So is there any slution by which I can see the text shown over there and so I can copy the remaining text in another JTextField
    I know there is some javax.swing.text.TextUI
    But I don't know how to find from that
    Thanks in advance
    CSJakharia

    968650 wrote:
    SELECT mkct_group_code FROM ID_MKT_CONTTYPE_GROUP_MASTER where mkct_group_code=20'
    Note mkct_group_code column is varchar2(10) type.
    It has values as
    20
    10
    30
    20'
    30' Oracle has introduced the Q notation to represent string literals. By using this you can specify your own separator.
    Example.
    If you want to pass a string as Hi it's Karthick's post
    Previously we use to do it like *'Hi it''s Karthick''s post'*
    But using the Q notation you can just do this *q'[Hi it's Karthick's post]'*. Here the Square brackets are the separators. Only thing you need to make sure is that the separator is not part of the actual string. You can specify any separator like q'|Hi it's Karthick's post|' or *q'{Hi it's Karthick's post}'* etc.

  • AutoComplete data bind issues

    I have an AutoComplete component in a viewstack which binds
    to correct value from a dataProvider and displays the selected
    value. Everything works beautifully until I select a different
    option and the databind stops working. The newly selected value is
    to be saved and associated with the AutoComplete as the default
    only after I click a button. When I "select" a different option and
    switch the view without clicking the save button and come back to
    the viewstack, the AutoComplete is supposed to display the initial
    value, instead it retains the value of the option selected last
    time. But if I clear the AutoComplete textInput, switch the view
    and come back it displays the correct value. Anyone come across
    similar problems? Any ideas?
    I tried to use the dataChange event to rebind but found that
    the dataChange event is never fired. Next thing I was thinking of
    doing was to have the application recreate the AutoComplete
    everytime the view is changed. Any ideas?

    I am going to give you a simpler example but you would do
    something like this:

  • Is there a way to Auto add the / while inputting a date into a textfield

    For example, if typing a date into a text file, is there a
    way to automatically add the /'s to the date as it's being
    typed?

    Scooby Doobie Doo wrote:
    > For example, if typing a date into a text file, is there
    a way to automatically add the /'s to the date as it's being typed?
    Yes

  • Is it possible to export interactive textfields with data?

    Hey guys,
    I have following problem. I´m creating our variable price list for our customers. "variable" means an interactive pdf for our customers where they can edit the prices, product discription etc.
    I can paginate our catalogue with "Easy Catalogue" including all interactive textfields. It looks like this:
    https://www.dropbox.com/s/kn81v9db69dx0a7/screenshot_pagination_incl_interactive_textfield s.png?dl=0
    The problem now is, when I export it as an interactive pdf, the data of the textfields will not be exported -> Dropbox - screenshot_exported_interactive_form.png
    it`s just blank
    Does anybody have a solution for this problem. I need the fields to be preset with the data!
    Is it generally possible to export interactive textfields with data?
    Any idea is appreciated!
    cheers from Austria,
    Chris

    I´m using Easy Catalog http://www.65bit.com/software/easycatalog/
    But I think it has something to do with indesign interactive pdf export properties.
    What I also tried:
    Converted an ordinary textfield with text into an interactive textfield -> then exported as an interactive pdf -> also blank editable field!

  • How to get data from textfield from an other class

    Hello everyone,
    I have a problem with an application I am writing for school. I want to get the data from a textfield into an other class.
    I have two classes: KlantGui and KlantMenuGui
    Some Codes from KlantGui:
    public String klantNummer;
    //knr
    knr = new JTextField(10);
    p2.add(knr);
    //getValue
    public String getValue() {
         return knr.getText();
    //getKlantNummer
    public String getKlantNummer(){
         klantNummer = getValue();
         return klantNummer;
    }And this one is from KlantMenuGui:
    private KlantGui kg = new KlantGui();
    //This is where I want the data to display
    String klantnr = kg.getKlantNummer();
    p2.add(new JLabel (" Klantnr: "));
    tf4 = new JTextField (10);
    p2.add(tf4);
    tf4.setEditable(false);
    tf4.setText(klantnr);I don't know why but it seems like the getValue() doesn't sends the data. For example if I write klantNummer = "2" instead of klantNummer = getValue(); it does work and I see 2 in the other class.
    Thanks!

    Does knr ever get populated?
    From the code below, you create an instance of a KlantGui, but this will have no values set, then straight away call getValue, which returns "", which is correct since the textfield for the instance of KlantGui just created would be empty?

  • Dynamic Select List based on TextField data

    Hi,
    I like to dynamically display the select list based on the value in the textfield, the data in the textfield is of character type.
    Thanks

    Hello,
    Well as you now know HTML based select lists don't work like that, that widget is called a combo box and there will be built in combo boxes in APEX 3.0, it's a fairly complex dhtml widget.
    What you might want to do is provide a text item next to your select box and an Add New Value Option in your select list.
    Carl

  • Set TextField value when Data present.

    I have a form that I want prices to appear when data in a textfield is present. So If "TextField A" contains any data have TextField B show $20.00. If "TextField A" becomes blank "TextField B" is blank also.

    Hi,
    If you place the following Javascript in the calculate event of TextFieldB,
    if (TextFieldA.rawValue != null)
         this.rawValue = "$20.00";
    else
         this.rawValue = null;
    That should work,
    Niall

  • Data can not be transfered in "" Problem : WebService in Interactive FOrm

    Hi everyone,
    According to a tutorial I built a simple PDF Form with WebService as Data Connection (One textfield as input and one button to call the webservice). The WebService is tested in WSNavigator successfully.
    The button is defined as an execution button on server side and with operation from the WS.
    However as I clicked on the button in PDF, I got warning: Data can not be transfered in ""
    I'm not very sure what it means. From the XMLSource i didn't recongnize any error. So just want to ask, if someone has idea. Many thanks in advance.
    Br,
    Bill

    Thank you for your message. It has been forwarded to another of my mail-accounts. Therefore it might take some time to respond.
    To avoid any delays in future, please request in another mail to this address my new mail id. It is not given here as this automatic message will be sent to spam providers, too.
    Kind regards,
    Volker
    Vielen Dank für Ihre Nachricht. Diese wurde an eine weitere meiner E-Mail-Adressen weitergeleitet. Daher kann sich meine Antwort etwas verzögern.
    Um künftige Verzögerungen zu vermeinden, erfragen Sie bitte in einer separaten Nachricht an diese Adresse meine neue E-Mail-Adresse. Diese ist nicht an dieser Stelle erwähnt, da diese automatische Nachricht auch an Spammer gesandt wird.
    Viele Grüße,
    Volker Müller

Maybe you are looking for