Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6603345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:59:48+00:00 2026-05-25T18:59:48+00:00

I have 2 JtextFields called qty and amount. When the user types in qty,

  • 0

I have 2 JtextFields called “qty” and “amount”. When the user types in qty, the value is gone under some calculation and set the last value to amount textfield. I have bound these 2 textfields to beansbinding class’s properties. when the user types in qty, the property which is responsible for that textfield is called and then I have called the firepropertychange of the qty as well as the amount’s firepropertychange to update the value of amount according to the qty. This works well.Also when qty’s textfield’s value is being deleted with backspace button the qty’s value also change.but when qty textfield is empty, the amount textfield remains with its last value(let’s say qty is having a number ’22’ and amount textfield shows ’44’, and when backspace is pressed the number is ‘2’ and amount’s showwing value is ‘4’,but when the last value ‘2’ in qty is aslo deleted, the amount textfield shows ‘4’).I want that the amount textfield should be showing zero.

Any solution for this please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:59:49+00:00Added an answer on May 25, 2026 at 6:59 pm

    just checked the default converters: they don’t handle null/empty, you have to implement one that can do and set that to the binding. Something like, to see the difference uncomment the converter setting:

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private void bind() {
        BindingGroup context = new BindingGroup();
        AutoBinding firstBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
              // this is some int property
                this, BeanProperty.create("attempts"), 
                fields[0], BeanProperty.create("text"));
        context.addBinding(firstBinding);
        // firstBinding.setConverter(INT_TO_STRING_CONVERTER); 
        context.bind();
    }
    
    static final Converter<Integer, String> INT_TO_STRING_CONVERTER = new Converter<Integer, String>() {
        @Override
        public String convertForward(Integer value) {
            return Integer.toString(value);
        }
    
        @Override
        public Integer convertReverse(String value) {
            if (value == null || value.trim().length() == 0) return 0;
            return Integer.parseInt((String) value);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JPanel with two JTextFields. If the user writes some text into
I have a page where some products and textfields where the user enters a
I have Java application which adds JTextFields @ runtime to JPanel. Basically user clicks
I have a JPanel full of JTextFields... for (int i=0; i<maxPoints; i++) { JTextField
This one's a tough one - I have a JFrame that generates JTextFields. When
I have a class with 4 arrays: tab_1,tab_2,tab_3 and tab_T. I set the picker's
How do I make a delegate? I have a class called CustomSign. The class
I have a form which user enters data and upload a picture, when user
Sorry for my English. I have some problems with JTextField and with KeyListener. I
this is my first question on stack overflow but I have some experience in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.