[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

JFormattedTextField, NumberFormatter etc.

Posted on 2003-12-11
3
Medium Priority
?
357 Views
Last Modified: 2010-08-05
Does anyone know how to set a formatter object on a JFormattedTextField (JFTF) *AFTER* it's created?? (without subclassing it?)

The JFTF is being constructed from an XML file parsed with a SAX parser; the way I implemented it, I really need (want) to call the default constructor in one method, and set it's attributes with another.

I can get the JFTF to work if I set the formatter in the constructor, but I simply don't have the attributes handy when I'm constructing it.

Well, actually I do, but I can use a really sweet algorithm if I could set the attributes after the JFTF is constructed.

setFormatter() is protected; JFormattedTextField.AbstractFormatter.install() isn't what I thought it was...  The documentation is surprisingly limited, and I have yet to find an example where they don't set the formatter in the constructor.

Thanks,

Shawn
0
Comment
Question by:ShawnCurry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 9925719
try setting the formatter factory.
0
 
LVL 3

Author Comment

by:ShawnCurry
ID: 9925799
Yup..  got it.. I'm really appreciating the open source..  Just had to figure out how it works...

JFormattedTextField ftf = new JFormattedTextField();
DefaultFormatterFactory df = new DefaultFormatterFactory(
      new NumberFormatter( NumberFormat.getIntegerInstance()));
ftf.setFormatterFactory(df);

That's a heck of a wrapper... Oh well..

Thanks again.
0
 
LVL 92

Expert Comment

by:objects
ID: 9925828
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question