Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

jFormattedTextField

Thread view: 
GreenMountainBoy - 22 Jan 2007 22:31 GMT
Could someone post an example of using jFormattedTextField for
inputting a fixed width field accepting whole numbers only? I sure
would appreciate it! I have been experimenting with this
jFormettedTextFielld and am having trouble with the example from the
Sun API.

Thanks a million.

GreenMountainBoy
Knute Johnson - 23 Jan 2007 00:43 GMT
> Could someone post an example of using jFormattedTextField for
> inputting a fixed width field accepting whole numbers only? I sure
[quoted text clipped - 5 lines]
>
> GreenMountainBoy

import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.*;
import javax.swing.text.*;

public class test extends JFrame {
    public test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        try {
            MaskFormatter mf = new MaskFormatter("####");
            JFormattedTextField tf = new JFormattedTextField(mf);
            add(tf,BorderLayout.CENTER);
        } catch (ParseException pe) {
            pe.printStackTrace();
        }

        pack();
        setVisible(true);
    }

    public void actionPerformed(ActionEvent ae) {
        String ac = ae.getActionCommand();
    }

    public static void main(String[] args) {
        Runnable r = new Runnable() {
            public void run() {
                new test();
            }
        };
        EventQueue.invokeLater(r);
    }
}

Signature

Knute Johnson
email s/nospam/knute/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.