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 8642829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:52:46+00:00 2026-06-12T11:52:46+00:00

I am trying to create a Java windows application using the WindowBuilder plug-in in

  • 0

I am trying to create a Java windows application using the WindowBuilder plug-in in Eclipse. I have a JTextField that works fine, on entry of the required values. But, when I clear all the contents on the field and try to re-enter other values, the values are disoriented i.e., the values don’t appear at all, or seem to appear in the next line.

I’m using a DocumentListener, so yes, this might result in an empty string exception. But, I’m not sure why the contents of the JTextField are inappropriate on re-entry.

PFB my piece-of-code:

void computeTotal(final JTextField jtf){
    jtf.getDocument().addDocumentListener(new DocumentListener(){
        public void changedUpdate(DocumentEvent e) {
            //warn();
            getTotal();
        }
        public void removeUpdate(DocumentEvent e) {
            //warn();
            getTotal();
        }
        public void insertUpdate(DocumentEvent e) {
            //warn();
            getTotal();
        }
        public void getTotal(){
            bt = Float.parseFloat(billTotal.getText());
            bd = Float.parseFloat(billDeduction.getText()) ;
            ta = Float.parseFloat(taxAmt.getText());
            tt = bt - bd+ ta;
             totalTotal.setText(tt+"");
        }

    });
    }

What is the problem here?

  • 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-06-12T11:52:47+00:00Added an answer on June 12, 2026 at 11:52 am

    What is the problem here?

    • use JFormattedTextField formatted by Number Formatter, then is DocumentListener correct listener

    • no parsing needed, no issue with nice output, thoushand separator, input of non number chars arenot allowed

    • use DocumentFilter with Patern, there you can remove non number chars and then you can parse with quite save contens contains numbers, decimal separator and negative sing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to program a java application that consists of several windows using
I have created an executable java Swing .jar application. It works fine on Windows.
I am trying to create a GUI using java swing. From there I have
I'm trying to create a Qt main windows from Java using JNI directly and
I have an web application that I was trying deployed on a remote windows
I am trying to create a small Java application using Tomcat and am having
I have an SWT application that I'm trying to create a runnable .jar for;
I'm trying to create a Java swing application and I'm trying to use a
I'm trying to create a simple Java app that uses JNI to call some
I am trying to create a directory in Java. I think I have provided

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.