Retrieve unformatted text from JFormattedTextField

Hi everyone,
I'm using FormattedTextField to define my formatted text fields and I'm using MaskFormatter to set the format.
I've been trying (with no success :( ) to find a way to retrieve the unmasked text that has been set for a text field.
For example, if the formatter is :
new MaskFormatter("(###)###-###"), then the text field will display the input as:
(342)123-455.
I need to retrieve the text as : 342123455.
I expected to find a parse or a getUnmaskedText methods in one of these class, but there is none.
Any idea will be appreciated.
Thanks!

Maybe I'm missing something but here is the code:
import javax.swing.*;
import javax.swing.text.MaskFormatter;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.*;
import java.text.*;
import javax.swing.text.*;
public class FormatEx3 extends JPanel {
MaskFormatter formatter1 = null;
private JFormattedTextField field1;
private JButton getValueBtn;
public FormatEx3() {
super(new GridLayout(1, 3));
setUpField1();
displayFields();
private void displayFields() {
getValueBtn = new JButton("Get Phone NUmber");
add(new JLabel("Phone:"));
add(field1);
add(getValueBtn);
getValueBtn.addActionListener(new ButtonAdapter());
private void setUpField1() {
try {
formatter1 = new MaskFormatter ("(###)###-####");
formatter1.setPlaceholderCharacter('_');
field1 = new JFormattedTextField(formatter1);
field1.setFocusLostBehavior(JFormattedTextField.PERSIST);
} catch (java.text.ParseException exc) {
public static void main(String[] args) {
JFrame frame = new JFrame("Formatted Text Field Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 70);
frame.getContentPane().add(new FormatEx3());
frame.setVisible(true);
class ButtonAdapter implements java.awt.event.ActionListener {
public void actionPerformed(ActionEvent e) {
try {
String str = (String) formatter1.stringToValue("(123)456-7890");
System.out.println("stringToValue: " + str);
field1.commitEdit();
String str1 = formatter1.valueToString(field1.getValue());
System.out.println("valueToString: " + str1);
} catch (ParseException ex) {
System.out.println(ex.getMessage());
Using formatter1.stringToValue("...") with a string that's not formatted return a parse exception. Try: formatter1.stringToValue("1234567890").
Using formatter1.stringToValue("(123)456-7890") returns (123)456-7890.
valueToString returns the formatted text or a parse exception is the string is incomplete: (111)23_-____
I hope I explained myself correctly.
I want to get/set unformatted text using a Formatter.
I've also tried to set an unformatted text to the field by using setText.
This call: field1.setText("1234567890") - will truncate the last 2 digits ....
So, again. My application saves the unformatted data. I want to be able to display it as formatted but retrieve it and set it as unformatted data.
Thanks everybody!

Similar Messages

  • Hw could copy a unformatted text from a formated paragraph

    Dear all,
    I am trying to copy an unformatted text from a formatted paragraph i have a code snippet, Please check it out and tell me that how can i copy a unformatted text from a paragraph. Result of this script should be a unformatted selected text...
    var par = app.selection[0].paragraphs[0];
        if (app.selection[0] instanceof InsertionPoint)
            if (par.characters[-1].contents != "\r")
                par.insertionPoints[-1].contents = "\r";
                par.characters.itemByRange(app.selection[0], par.insertionPoints[-1]).select();
                app.copy();
            else
                par.characters.itemByRange(app.selection[0], par.insertionPoints[-1]).select();
                app.copy();

    It's not the copy that 'removes' formatting, it's the paste that pastes without.
    Text can exist on the clipboard in any number of internal formats. It's possible to copy InDesign formatted text and paste it into a plain text editor -- so you won't get the formatting. But if you paste the same text again in InDesign, the formatting is still there.
    When copying, it's the responsibility of the copying program to put its copyable content in any useful format onto the global Clipboard.
    When pasting, a program should go through the list of supplied data formats (regardless of the source) and pick whatever it thinks is best. So, apparently, the usual Paste picks up InDesign "Native objects", while "Paste w/o Formatting" uses the plain (unformatted) text form.
    The only way to get an unformatted copy on the pasteboard would be to copy the string contents (raw ASCII characters) instead -- but InDesign's Javascript does not allow this. The app.copy() command only works on native InDesign objects.
    So, long story short, what you need can't be done.

  • How can I retrieve deleted texts from iPhone 4 with 6. Software?

    How can I retrieve old texts that have been deleted?

    I would use a program like iExplorer to perusue your backups.
    1. Search for iExplorer, download it, install it.
    2. Plug in your phone
    3. Click continue with Demo on the lower right
    4. On the left side panel select "Browse iTunes Backups"
    5. From here select the iOS device and then click Messages... now you can look through your messages..buying iExplorer will allow you to search your messages.
    Also, check out DiskAid, I believe it will let you look through your backups and search may work without purchasing, just understand that both programs will have some limitation in demo mode.
    Aaron

  • HT1766 How do I retrieve deleted texts from my iphone

    I accidentally deleted a text from my iphone on July 11th. I need to retrieve that message, and I have no back up of it. Thanks!

    With no backup, you'll have to use Google & search for one of the many paid programs that "claim" to be able to retrieve deleted SMS's from an iPhone.
    Whether any work or not, I have no idea.

  • HT4859 how do i retrieve old text from previous phone to new phone

    i was told by apple care that if i purchased a new iphone that i would be able to retrieve old messages from my 4s to my iphone 5.. but i cant figure out how

    Or you can check this iphone to iphone sms transfer tutorial. Best luck!

  • How can I retrieve all texts from lost iPhone 6 plus left in lost mode?

    How can I retrieve all new texts going to my  lost iPhone 6 plus left in lost mode, through a browser or my wifi iPad ?

    Not through a browser.  If iMessage, set iPad to receive messages sent to your cell number:
    Settings > Messages > Send & Receive > You can be reached by iMessage at >
    SMS/MMS - no

  • Retrieve deleted text from my phone never synced or backed up phone

    So... I need to get my deleted text and safari history that has been deleted. I have not backed up to itunes in about a year,  or to icloud. Also if I do sign in to icloud my pics, mai,l safari, and message back up dont even show up on my icloud home screen or anywhere. I try to click help and its no help at all. PLEASE HELP ME!!!!

    The iCloud and the iTunes are the 2 options you have to save your data bro, otherwise you losted.
    Regards.

  • If I have backed up my icloud account on my computer can someone later go to that computer and retrieve my emails from the harddrive of the computer.

    If I have backed up my phone to my iclouds on a computer can anyone retrieve my texts from the harddrive of my computer

    But they just have to have the password to my computer
    Yes.
    If they also have your icloud password as well, then you are really in trouble. If they know where to look, they may find it.

  • Cant return text from class

    Hi guys,
    I'm hopeing someone out there can help me out with a problem that has been bothering me for the last few days. Basically I can not get my class to return any text at all by calling the appropriate function, yet if I do a system.out.println() from within the class its self the text will be outputed to the console without a problem.
    Below is the threaded class I want to retrieve the text from:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class SockThread implements Runnable{
         private String chatter;
         public String chatText;
         private String charText;
         private Thread runner;
         private Socket socktest;
         private PrintStream out;
         private BufferedReader in;
         public SockThread() {
              if (runner == null) {
                   runner = new Thread(this);
                   runner.start();
         public void run() {
              try {
                   this.connect();
              } catch (IOException ioe) {
         public void connect() throws java.io.IOException{
              String hostname = "efnet.xs4all.nl";
              int portnumber = 6669;
              this.socktest = new Socket(hostname, portnumber);
              this.out = new PrintStream(this.socktest.getOutputStream());
             this.in = new BufferedReader(new InputStreamReader(this.socktest.getInputStream()));
              this.out.print("user "+ "strangename" + " stranger irc : " + "Stranger");
              this.out.print("\n");
              this.out.print("nick " + "Shadwick");
              this.out.print("\n");
              Boolean eof = false;
                   try {
                        while (!eof) {
                             this.charText = in.readLine();
                                  if (this.charText == null){
                                       eof = true;
                                       socktest.close();
                                  } else {
                                       this.chatText = charText;
              } catch (IOException ioe) {
                   System.out.println("Its not working :( " + ioe);
         public void showStatus() {
              System.out.println(this.chatText);
    }And here is my main class:
    public class ChatConsole {
         public static void main(String[] arguments) {
              SockThread st = new SockThread();
              st.showStatus();
    }No matter if i try accessing the text via the showStatus() function or directly access the chatText variable i get nothing. I'm pretty sure i'm missing something thats stopping me from getting the text but I just cant see it. If anyone can help I'd greatly appreciate it.

    As you are creating another thread with the SockThread class, it runs independently from the main thread. So the SockThread Thread has probably not gotten to the part where it initiates the chatText var by the time the main thread calls the showStatus() method.
    To varify this, either do:
    put System.out.println("TEST"); in the show status method. If this prints then the var just hasnt been initiated yet.
    OR
    Use Thread.Sleep(2000); in the main method to make is sleep for a while to give the SocketThread Thread a chance to initiate the var.

  • How can I retrieve deleted text messages from my iphone 5

    Somebody deleted a string of text messages from my iPhone 5 and I want to know if they can be retrieved and if so how? I'm new to the iPhone as this is my first apple product.  I am still not even sure on how to use my iTunes and so forth.  Please help as the string of messages was very important!! Thank you so very much!! Tracy

    SMS text messages are backed up with the iPhone - whether it's locally or to iCloud. If you've already written over the backup that had them (as in, backed up after the delete) then they're gone.
    If you still have a backup available from a time where you had the messages on your iPhone, all you have to do is erase the iPhone and restore from that backup.
    "Retrieve deleted messages from iPhone" is simple as pie.

  • Is there a way to retrieve a text message that has been deleted from my iphone?

    Is there a way to retrieve a text message that has been deleted from my iphone?  I did't delete the message but after i synced my phone the message was gone.

    No, the app doesn't use Safari.  The app is AutoDesk Inventor Publisher Viewer.  I think there is a way that you can have a publish Inventor file, and if you create a correctly formatted hyperlink, you can click on it and it will immediately open the file in the viewer.
    I know that if you offer the file as a standard download, iOS will ask whether you want to open it with Inventor Pub. Viewer or save it to another app that can accept files.  I would prefer to skip the prompt, and just open the viewer.
    I've heard mention that this can be done with this application, but I can't find reference material anywhere.

  • Retrieve text from sprite at specific marker

    Is there a way to retrieve text from a spriteMember at a
    specific marker when you are not located at that marker?
    I have an presentation that uses small graphics at the bottom
    to jump to it's corresponding marker based on the markerList. I
    would like to retrieve the text in sprite(6) from the corresponding
    marker location and display it in a text sprite on the stage at the
    current location. Without jumping to that location.
    I'm trying to avoid making a list or naming the members with
    the corresponding marker.
    Thanks.
    Wally

    >>Is there a way to retrieve text from a spriteMember
    at a specific marker
    >>when you are not located at that marker?
    Short answer... no.
    Can you get the text of the member?
    If that won't work you can use the updateLock property of
    score recording.
    You can do something like this: set updateLock to true, go
    the frame you
    want, get the text of the member of the sprite, then return
    to the frame you
    were at and turn updateLock back to false.
    on test
    _movie.updateLock = true
    go "spriteFrame"
    put sprite(6).member.text
    go "normalFrame:
    _movie.updateLock = false
    end
    If you place that as a handler in a movie script, you can
    enter test from
    the message window and see what happens - you will see the
    text of the
    sprite displayed, but the play head won't move...
    HTH
    Dave -
    Adobe Community Expert
    www.blurredistinction.com
    http://www.adobe.com/communities/experts/

  • Is there any way to access my old my verizon account to retrieve old text messages from my own old account from 8 months ago?  I am getting a divorce and I need info off of that account for my hearing to prove what he did.

    Is there any way to access my old my Verizon account to retrieve old text messages from my own old account from 8 months ago?  I am getting a divorce and I need info off of that account for my hearing to prove what he did.

    What do you mean by "when I brought the messages up back in March"?
    Were the messages on your phone? Simply because messages are on your phone does not mean they are still on Verizon's servers. You use internal phone memory to store messages on your phone. The messages do not stay on Verizon's servers until you delete them from your phone.
    On the other hand, if you still have your phone and have not reset it since you stopped using it, the texts may still be on your phone. Good luck.

  • How to retrieve only the text from a multiline Varchar2 field?

    Dear Friends,
    I have a text in a varchar2 field having text only in line2.
    I want to retrieve the text only skipping the blank line.
    The syntax REPLACE(FIELD_NAME,CHR(10),'') is not working.
    Please help me.
    Thanking you,
    With Regards
    Franklin

    there must be other characters in your text field that are not chr(10) (line feeds etc).
    use a regular expression to replace all the non-printable characters:
    select regexp_replace(field_name,'[^[:print:]]') from table

  • HT201210 how can i retrieve texts from an earlier back up without changing all the other settings on my iphone?

    how can i retrieve texts from an earlier back up without changing all the other settings on my iphone?

    You can't. Restoring from a backup is all or none.
    You can use a utility such as this one to extract the messages from the backup on your computer but you can't re-transfer the messages to the Messages app on your iPhone.
    http://msb.macsupport-pr.com/

Maybe you are looking for

  • Billing Document _ Accounting Document not created

    Dear SD Experts, While creating billing document, the accounting document was not created.  So, the debit entry in customer account was not made. But the Excise Invoice was created with reference to this billing document. Modvat was also utilized. Th

  • Is telnet use local tnsnames.ora?

    I was suprise that when the local tnsnames.ora of client was not correct,sqlplus at telnet can't connect to server,and when the file was modify,I can use sqlplus connect to oracle through telnet. is telnet use local tnsnames.ora?

  • Create a view similar to Maintenance view

    Hello Abap Experts, How to create a DB view similar to maintenance view. what are the steps to be followed. Thanks, BWer

  • Error while attempting to install i-tunes

    I have been trying to install my sons Nano for an hour now. I got yhe nano software installed but I cannot get the Itunes to install I am getting this error: 1402. Could not open key: HKEYLOCALMACHINE\Software\classes\.cdda\Openwithprogids. Verify th

  • Ringtone File

    Sorry if I cant ask this but this is the only place that has the right answers. I had a ringtone app and loved it all of it worked great. Recently I had to take in my computer to get fixed (never doing that again) and all of it started screwing up. I