Solved

Adding a "formatter" to an editable JComboBox

Posted on 2004-09-26
3
424 Views
Last Modified: 2008-01-16
Hi,

How do I make an editable JCombobox behave like a JFormattedTextFiled with a Formatter (i.e. not allow certain characters such a commas and periods)?

Thanks,

Cmp2
0
Comment
Question by:cmp2
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
nesnemis earned 125 total points
ID: 12157725
You can use DocumentFilter on the strings that you want to input in your comboboxes
0
 

Author Comment

by:cmp2
ID: 12162182
Thanks nesnemis,

I know how to add a DocumentFilter on a text field, but how do you add a FilterDocument to a JComboBox?

Cmp2
0
 

Author Comment

by:cmp2
ID: 12162381
Nevermind, I figured it out.

JComboBox a = new JComboBox();
JTextField c = (JTextField)a.getEditor().getEditorComponent();
c.setDocument(...);

Thanks for the suggestion.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ArrayIndexOutOfBoundException 9 83
how to install java on RHEL image on EC2 4 28
login form jsp example 2 26
Html Table Looping (part 2) 5 8
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 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