Solved

JFormattedTextField, NumberFormatter etc.

Posted on 2003-12-11
3
354 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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

705 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