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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:40:57+00:00 2026-06-10T11:40:57+00:00

In my current project, I am storing a currency value as an int which

  • 0

In my current project, I am storing a currency value as an int which represents the number of cents. However, when the user inputs this value in a text field, they will most likely expect to enter it as a decimal value. Also, I would like to prepend a dollar sign if the user doesn’t enter it manually. How can I leverage a JFormattedTextField to do much of this work for me? Or is there other solutions using pre-existing Swing components so that I don’t have to reinvent the wheel by coding this all by hand?

  • 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-10T11:40:58+00:00Added an answer on June 10, 2026 at 11:40 am

    The NumberFormat is also suited to format a currency (see NumberFormat#getCurrencyInstance). And since you need a Format for the JFormattedTextField I would start there.

    You can configure the NumberFormat to allow decimal values, and convert it later on in your code to an int without problems

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

Sidebar

Related Questions

On my current project, which is a delivery system, I have a list of
I am working on a project which basically involves parsing and storing information about
In my current project, I have classes which are modeled like the following. At
I'm working on a zend project which has functionality based on user logged minutes.
For my current project I'm using Mercurial and hosting it on Bitbucket. This was
Current project, broke head over this problem: Client Repository: public class ClientRepository { //
On my current project, to get a single value (select column from table where
In my current project, I am using Memcache to store key-value pairs, but since
I have a project which provides users with a list of current tasks that
In my current project I need to perform a few native queries which pick

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.