Netbeans form editor and JFormattedTextField

Discussion in 'Java' started by Mack Attack, Sep 15, 2003.

  1. Mack Attack

    Mack Attack Guest

    The Netbeans form editor uses parameterless constructors for all components.
    I don't think there is any way around this.

    I want to use a JFormattedTextField and have it set to use a specific format.
    If I wasn't using the form editor I would do something like this:

    NumberFormat percentFormat = NumberFormat.getNumberInstance();
    percentFormat.setMinimumFractionDigits(3);
    myFormattedTextField = new JFormattedTextField( percentFormat );

    How can I do the same thing with the JFormattedTextField created by the form?
    I've looked at setFormatter and setFormatterFactory but they have me completely
    confused.

    Thanks
     
    Mack Attack, Sep 15, 2003
    #1
    1. Advertising

  2. Mack Attack wrote:

    > The Netbeans form editor uses parameterless constructors for all
    > components. I don't think there is any way around this.
    >
    > I want to use a JFormattedTextField and have it set to use a specific
    > format. If I wasn't using the form editor I would do something like this:
    >
    > NumberFormat percentFormat = NumberFormat.getNumberInstance();
    > percentFormat.setMinimumFractionDigits(3);
    > myFormattedTextField = new JFormattedTextField( percentFormat );
    >
    > How can I do the same thing with the JFormattedTextField created by the
    > form? I've looked at setFormatter and setFormatterFactory but they have me
    > completely confused.
    >
    > Thanks


    Select the JFormattedTextField in the gui designer.
    Then go to the "code generation" tab of the properties panel.
    Select the "custom creation code" field.
    Type "new JFormattedTextField( percentFormat );" (without the quotes
    ofcourse) in the field.

    You can also set the Numberformat part in the
    "pre-creation code" field.

    --
    mvg,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Sep 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wolfgang wagner

    JFormattedtextField - formatting user input

    wolfgang wagner, Jul 9, 2003, in forum: Java
    Replies:
    0
    Views:
    465
    wolfgang wagner
    Jul 9, 2003
  2. Steve Webb
    Replies:
    4
    Views:
    4,068
    Webby
    Apr 29, 2004
  3. Stylus Studio
    Replies:
    0
    Views:
    736
    Stylus Studio
    Aug 3, 2004
  4. Francois
    Replies:
    0
    Views:
    404
    Francois
    Nov 8, 2006
  5. I82Much
    Replies:
    0
    Views:
    1,339
    I82Much
    May 5, 2009
Loading...

Share This Page