Results 1 to 4 of 4
  1. #1
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Post Please help, this code cant work on netbeans, althought its true

    Please help,, this code works 100 %,, but i cant make it working on netbeans
    i dragged and dropped jformatted text field but i dont know where to put the mask !! PELASE PLEASE HELP!!!:D

    Java Code:
    MaskFormatter mask = null;
    	 	try {
    			mask = new MaskFormatter("(###) ###-####");
    		} catch (ParseException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	 	
    		JFormattedTextField phoneField = new JFormattedTextField(mask);
    		phoneField.setPreferredSize(new Dimension(100, 20));

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    In NetBeans design mode, right click on the JFormattedTextField component that you've dropped into your app to bring up the component-specific pop-up menu and then click on the "Customize Code" menu item. You'll want to add this code to the top in pre-creation section:

    Java Code:
        MaskFormatter mask = null;
    	 	try {
    			mask = new MaskFormatter("(###) ###-####");
    		} catch (ParseException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}

    Then in the component's constructor pass the mask variable. You'll need to import the MaskFormatter and ParseException classes for this to work.

  3. #3
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Default

    it didnt work it gives this error

    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class MaskFormatter
    location: class databasepharmacy.EmployeeFrame

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by javanew View Post
    it didnt work it gives this error

    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class MaskFormatter
    location: class databasepharmacy.EmployeeFrame

    You may have missed a part of my post. To reiterate:


    Quote Originally Posted by Fubarable View Post
    ...You'll need to import the MaskFormatter and ParseException classes for this to work.

Similar Threads

  1. my simple boolean code keeps saying true
    By shazakala in forum New To Java
    Replies: 8
    Last Post: 03-27-2011, 10:30 AM
  2. project runs in netbeans but .jar wont work
    By Zeo7 in forum New To Java
    Replies: 3
    Last Post: 12-16-2010, 04:21 PM
  3. This code doesn't work. Why? thanks.
    By seanzhang in forum New To Java
    Replies: 10
    Last Post: 07-09-2010, 05:53 AM
  4. Why this code don't work?
    By artemff in forum CLDC and MIDP
    Replies: 6
    Last Post: 04-16-2010, 02:57 AM
  5. setVisible(true) does not work
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 2
    Last Post: 10-27-2007, 07:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •