Formatting a textfield

I would like to format a text field to accept a phone number eg (***) *** - ****
How do I create this mask?
I have seen JMaskField mentioned but I can not find any examples. Could anyone provide an example of how to use JMaskField or have you got any other suggestions?
Thank you

hi soughtred,
Try the following code. I hope this is what you want.
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
class MaskedTextField extends JTextField {
public MaskedTextField (String mask, String initStr) {
super();
setDocument(new MaskedDocument(initStr, mask, this));
setText(initStr);
setColumns(mask.length()+1);
class MaskedDocument extends PlainDocument {
String mask;
String initStr;
JTextField tf;
public MaskedDocument(String initStr, String mask, JTextField container) {
this.mask = mask;
this.initStr = initStr;
tf = container;
void replace(int offset, char ch, AttributeSet a)
throws BadLocationException {
super.remove(offset,1);
super.insertString(offset,""+ch,a);
public void remove(int offs, int len) throws BadLocationException {
System.out.println("R:"+len+","+offs);
if (len==0)
return;
// Remove current contents
super.remove(offs, len);
// Replace the removed part by init string
super.insertString(offs,initStr.substring(offs,offs+len),
getAttributeContext().getEmptySet());
tf.setCaretPosition(offs);
public void insertString(int offset, String str, AttributeSet a)
throws BadLocationException {
if ((offset==0) && str.equals(initStr)) {
// Initialisation of text field
super.insertString(offset,str,a);
return;
if (str.length()==0) {
super.insertString(offset,str,a);
return;
for (int i=0;i<str.length();i++) {
while ((offset+i) < mask.length()) {
if (mask.charAt(offset+i)=='-')
// Skip fixed parts
offset++;
else {
// Check if character is allowed according to mask
switch (mask.charAt(offset+i)) {
case 'D': // Only digitis allowed
if (!Character.isDigit(str.charAt(i)))
return;
break;
case 'C': // Only alphabetic characters allowed
if (!Character.isLetter(str.charAt(i)))
return;
break;
case 'A': // Only letters or digits characters allowed
if (!Character.isLetterOrDigit(str.charAt(i)))
return;
break;
replace(offset+i, str.charAt(i),a);
break;
// Skip over "fixed" characters
offset += str.length();
while ((offset<mask.length()) && (mask.charAt(offset)=='- ')) {
offset++;
if (offset<mask.length())
tf.setCaretPosition(offset);
public class test {
public static void main(String[] args) {
final JFrame f = new JFrame("Textfield demo");
f.setDefaultCloseOperation(f.DISPOSE_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
System.exit(0);
f.setSize(250,70);
MaskedTextField tf=new MaskedTextField("DD-D-D-DDD-DDDD","..-
tf.setFont(new Font("Monospaced", Font.BOLD, 14));
JPanel panel = new JPanel();
panel.add(tf);
f.getContentPane().add(panel);
f.setVisible(true);

Similar Messages

  • How can I format a textfield control according to column width?

    Hi!
    Someone can help me?
    I have a column on the database that is VARCHAR2(2).
    On the frame , I want that the user enter a value delimited with 2 characters, but I don't now how.
    I have changed de property of the column on the rowset of the view, but I don't have success.
    Thank4s in advance for any help.
    Vania
    (Sorry for my bad english)

    Here it is.
    You can inastantiate a text field object of following class(limited two char input) like this:
    myUpperCaseField myField = new myUpperCaseField(2);
    Note: this class also upper cased the char input. You should doing some change in this code,if you are not concern on upper case.
    import javax.swing.text.*;
    import oracle.dacf.control.swing.*;
    import java.awt.Toolkit;
    public class myUpperCaseField extends TextFieldControl {
    int fixedLength=0;
    public myUpperCaseField(int cols) {
    super(cols);
    fixedLength = cols;
    public myUpperCaseField() {
    super();
    fixedLength = 0;
    protected Document createDefaultModel() {
    return new UpperCaseDocument();
    public void setFixedLength(int length){
    if(length < 0){
    fixedLength = 0;
    else{
    fixedLength = length;
    public int getFixedLength(){
    return fixedLength;
    protected class UpperCaseDocument extends PlainDocument {
    public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
    if(getFixedLength() > 0){
    if(getLength() + str.length() > getFixedLength()){
    Toolkit.getDefaultToolkit().beep();
    return;
    if (str == null) {
    return;
    char[] upper = str.toCharArray();
    for (int i = 0; i < upper.length; ++i) {
    upper[i] = Character.toUpperCase(upper);
    super.insertString(offs, new String(upper), a);
    }//end of class
    null

  • Format Date TextField using Locale for international apps

    Hello there...
    I am developing an application and I want it to be easily converted to different languages.
    In Brazil, we use the date like dd/MM/yyyy. In the USA, it is MM/dd/yyyy.
    My question is: how can I get the text from a text field and convert it to a Calendar using a Locale (or the default Locale)? I don't want something like
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    I would like something like:
    SimpleDateFormat formatter = new SimpleDateFormat(locale);
    The constructor SimpleDateFormat () without arguments says it builds the parser based on the Locale, but I get a ParseException. I must always specify some parse mask.
    The second issue is the deprecation of a lot of things in java.util.Date. So, I would like to use a Calendar object to store the date, and without the warnings I get when I use date.getMonth() for example.
    My code is something like this:
    String text = dateField.getText();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    Date date = null;
    try {
    date = formatter.parse(text);
    } catch (ParseException ex) {
    ex.printStackTrace();
    Calendar calendar = null;
    if (data != null) {
    calendar = new GregorianCalendar();
    calendar.set(Calendar.DAY_OF_MONTH, date.getDate());
    calendar.set(Calendar.MONTH, date.getMonth());
    calendar.set(Calendar.YEAR, date.getYear());
    Thanks for helping!
    (Sorry the not so good english :) )

    My question is: how can I get the text from a text
    field and convert it to a Calendar using a Locale (or
    the default Locale)? I don't want something like Have you tried DateFormat.getDateInstance(int style, Locale aLocale)?
    And then is your second question just how to go from a parsed date to a Calendar?
    Calendar calendar = new GregorianCalendar():
    if (date != null)
      calendar.setTime(date);

  • TLF TextField - formatting issue - not working when TLF TF on stage?

    Hi,
    I have encountered formatting problems when using the TLF TextField placed on stage; I cant seem to format the textfield properly by ActionScript.
    When TLF TextField is created at runtime it works for strange reasons...
             import fl.text.TLFTextField;
          import flashx.textLayout.formats.TextLayoutFormat;
          import flashx.textLayout.elements.TextFlow;
          var myTLFTextField:TLFTextField = new TLFTextField();
          addChild(myTLFTextField);
          myTLFTextField.x = 10;
          myTLFTextField.y = 10;
          myTLFTextField.width = 200
          myTLFTextField.height = 100;
          myTLFTextField.text = "This is my text";
          var myFormat:TextLayoutFormat = new TextLayoutFormat();
          myFormat.textIndent = 8;
          myFormat.color = 0x336633;
          myFormat.fontFamily = "Arial, Helvetica, _sans";
          myFormat.fontSize = 24;
          var myTextFlow:TextFlow = myTLFTextField.textFlow;
          myTextFlow.hostFormat = myFormat;
          myTextFlow.flowComposer.updateAllControllers();
    When I set "myTLFTextField" as instance of an already existing TextField on stage no formatting is performed.
    I dont want to create all TLF TextFields by ActionScript, please help!

    I have yet to meet this beast called the TLFTextField, but I think in the forums I've more often seen recommendations to avoid it than to use it.  Did they miss a target when they invented it?

  • Android, backspace doesn't work properly in a flash.text.TextField

    Hello,
    I have a bug on my Nexus 5 Android 4.4 Air 4.0.
    when I scroll the text in the textField and I select the text (in my example near "subclass" word), the TextField get focus, if I put on the backspace key, the character deleted is the previous character the first time, and if I put again on the backspace key, the caracter deleted is the first character and not the previous character.
    package{
    import flash.text.TextField;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    public class Main extends Sprite {
      private var myTextField:TextField = new TextField();
      public function Main() {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;
        addEventListener(Event.ADDED_TO_STAGE, init);
      private function init(event:Event):void {
        myTextField.type="input";
        myTextField.text="The TextField class is used to create display objects for text display and input. You can give a text field an instance name in the Property inspector and use the methods and properties of the TextField class to manipulate it with ActionScript. TextField instance names are displayed in the Movie Explorer and in the Insert Target Path dialog box in the Actions panel.\nTo create a text field dynamically, use the TextField() constructor.\n\nThe methods of the TextField class let you set, select, and manipulate text in a dynamic or input text field that you create during authoring or at runtime.\n\nActionScript provides several ways to format your text at runtime. The TextFormat class lets you set character and paragraph formatting for TextField objects. You can apply Cascading Style Sheets (CSS) styles to text fields by using the TextField.styleSheet property and the StyleSheet class. You can use CSS to style built-in HTML tags, define new formatting tags, or apply styles. You can assign HTML formatted text, which optionally uses CSS styles, directly to a text field. HTML text that you assign to a text field can contain embedded media (movie clips, SWF files, GIF files, PNG files, and JPEG files). The text wraps around the embedded media in the same way that a web browser wraps text around media embedded in an HTML document.\n\nFlash Player supports a subset of HTML tags that you can use to format text. See the list of supported HTML tags in the description of the htmlText property.\n\nView the examples\n\nMore examples\n\nModifying the text field contents\nDisplaying HTML text\nUsing images in text fields\nScrolling text in a text field\nSelecting and manipulating text\nCapturing text input\nRestricting text input\nFormatting text\nWorking with static text\nTextField Example: Newspaper-style text formatting\nLearn more\n\nUse native features with a soft keyboard\nDisplay programming\nBasics of display programming\nCore display classes\nChoosing a DisplayObject subclass\nBasics of Working with text\nUsing the TextField class\nDisplaying text\nAdvanced text rendering\nRelated API Elements\n\nflash.text.TextFormat\nflash.text.StyleSheet\nhtmlText\n\nPublic Properties\n Show Inherited Public Properties\n   Property  Defined By\n      alwaysShowSelection : Boolean\nWhen set to true and the text field is not in focus, Flash Player highlights the selection in the text field in gray.\nTextField\n      antiAliasType : String\nThe type of anti-aliasing used for this text field.\nTextField\n      autoSize : String\nControls automatic sizing and alignment of text fields.\nTextField\n      background : Boolean\nSpecifies whether the text field has a background fill.\nTextField\n      backgroundColor : uint\nThe color of the text field background.\nTextField\n      border : Boolean\nSpecifies whether the text field has a border.\nTextField\n      borderColor : uint\nThe color of the text field border.\nTextField\n      bottomScrollV : int\n[read-only] An integer (1-based index) that indicates the bottommost line that is currently visible in the specified text field.\nTextField\n      caretIndex : int\n[read-only] The index of the insertion point (caret) position.\nTextField\n      condenseWhite : Boolean\nA Boolean value that specifies whether extra white space (spaces, line breaks, and so on) in a text field with HTML text is removed.\nTextField\n      defaultTextFormat : flash.text:TextFormat\nSpecifies the format applied to newly inserted text, such as text entered by a user or text inserted with the replaceSelectedText() method.\nTextField\n      displayAsPassword : Boolean\nSpecifies whether the text field is a password text field.\nTextField\n      embedFonts : Boolean\nSpecifies whether to render by using embedded font outlines.\nTextField\n      gridFitType : String\nThe type of grid fitting used for this text field.\nTextField\n      htmlText : String\nContains the HTML representation of the text field contents.\nTextField\n      length : int\n[read-only] The number of characters in a text field.\nTextField\n      maxChars : int\nThe maximum number of characters that the text field can contain, as entered by a user.\nTextField\n      maxScrollH : int\n[read-only] The maximum value of scrollH.\nTextField\n      maxScrollV : int\n[read-only] The maximum value of scrollV.\nTextField\n      mouseWheelEnabled : Boolean\nA Boolean value that indicates whether Flash Player automatically scrolls multiline text fields when the user clicks a text field and rolls the mouse wheel.\nTextField\n      multiline : Boolean\nIndicates whether field is a multiline text field.\nTextField\n      numLines : int\n[read-only] Defines the number of text lines in a multiline text field.\nTextField\n      restrict : String\nIndicates the set of characters that a user can enter into the text field.\nTextField\n      scrollH : int\nThe current horizontal scrolling position.\nTextField\n      scrollV : int\nThe vertical position of text in a text field.\nTextField\n      selectable : Boolean\nA Boolean value that indicates whether the text field is selectable.\nTextField\n      selectionBeginIndex : int\n[read-only] The zero-based character index value of the first character in the current selection.\nTextField\n      selectionEndIndex : int\n[read-only] The zero-based character index value of the last character in the current selection.\nTextField\n      sharpness : Number\nThe sharpness of the glyph edges in this text field.\nTextField\n      styleSheet : StyleSheet\nAttaches a style sheet to the text field.\nTextField\n      text : String\nA string that is the current text in the text field.\nTextField\n      textColor : uint\nThe color of the text in a text field, in hexadecimal format.\nTextField\n      textHeight : Number\n[read-only] The height of the text in pixels.\nTextField\n      textInteractionMode : String\n[read-only] The interaction mode property, Default value is TextInteractionMode.NORMAL.\nTextField\n      textWidth : Number\n[read-only] The width of the text in pixels.\nTextField\n      thickness : Number\nThe thickness of the glyph edges in this text field.\nTextField\n      type : String\nThe type of the text field.\nTextField\n      useRichTextClipboard : Boolean\nSpecifies whether to copy and paste the text formatting along with the text.\nTextField\n      wordWrap : Boolean\nA Boolean value that indicates whether the text field has word wrap.\nTextField";
        myTextField.border=true;
        myTextField.width=myTextField.height=300;
        addChild(myTextField);
    Thanks.

    I have this bug on Galaxy Nexus Android 4.3, I don't have this bug on Galaxy S Android 2.3, the bug occurs with the new Google Keyboard 3.0
    the app descriptor
    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <application xmlns="http://ns.adobe.com/air/application/4.0">
    <!-- Adobe AIR Application Descriptor File Template.
              Specifies parameters for identifying, installing, and launching AIR applications.
              xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/3.5
                                  The last segment of the namespace specifies the version
                                  of the AIR runtime required for this application to run.
              minimumPatchLevel - The minimum patch level of the AIR runtime required to run
                                  the application. Optional.
    -->
              <!-- A universally unique application identifier. Must be unique across all AIR applications.
              Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
              <id>TextFieldFB</id>
              <!-- Used as the filename for the application. Required. -->
              <filename>TextFieldFB</filename>
              <!-- The name that is displayed in the AIR application installer.
              May have multiple values for each language. See samples or xsd schema file. Optional. -->
              <name>TextFieldFB</name>
              <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
              Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
              An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
              <versionNumber>0.0.1</versionNumber>
              <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
              <!-- <versionLabel></versionLabel> -->
              <!-- Description, displayed in the AIR application installer.
              May have multiple values for each language. See samples or xsd schema file. Optional. -->
              <!-- <description></description> -->
              <!-- Copyright information. Optional -->
              <!-- <copyright></copyright> -->
              <!-- Publisher ID. Used if you're updating an application created prior to 1.5.3 -->
              <!-- <publisherID></publisherID> -->
              <!-- Settings for the application's initial window. Required. -->
              <initialWindow>
                        <!-- The main SWF or HTML file of the application. Required. -->
                        <!-- Note: In Flash Builder, the SWF reference is set automatically. -->
                        <content>[Cette valeur sera remplacée par Flash Builder dans le fichier app.xml de sortie]</content>
                        <!-- The title of the main window. Optional. -->
                        <!-- <title></title> -->
                        <!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. -->
                        <!-- <systemChrome></systemChrome> -->
                        <!-- Whether the window is transparent. Only applicable when systemChrome is none. Optional. Default false. -->
                        <!-- <transparent></transparent> -->
                        <!-- Whether the window is initially visible. Optional. Default false. -->
                        <!-- <visible></visible> -->
                        <!-- Whether the user can minimize the window. Optional. Default true. -->
                        <!-- <minimizable></minimizable> -->
                        <!-- Whether the user can maximize the window. Optional. Default true. -->
                        <!-- <maximizable></maximizable> -->
                        <!-- Whether the user can resize the window. Optional. Default true. -->
                        <!-- <resizable></resizable> -->
                        <!-- The window's initial width in pixels. Optional. -->
                        <!-- <width></width> -->
                        <!-- The window's initial height in pixels. Optional. -->
                        <!-- <height></height> -->
                        <!-- The window's initial x position. Optional. -->
                        <!-- <x></x> -->
                        <!-- The window's initial y position. Optional. -->
                        <!-- <y></y> -->
                        <!-- The window's minimum size, specified as a width/height pair in pixels, such as "400 200". Optional. -->
                        <!-- <minSize></minSize> -->
                        <!-- The window's initial maximum size, specified as a width/height pair in pixels, such as "1600 1200". Optional. -->
                        <!-- <maxSize></maxSize> -->
            <!-- The aspect ratio of the app ("portrait" or "landscape" or "any"). Optional. Mobile only. Default is the natural orientation of the device -->
            <!-- <aspectRatio></aspectRatio> -->
            <!-- Whether the app will begin auto-orienting on launch. Optional. Mobile only. Default false -->
            <!-- <autoOrients></autoOrients> -->
            <!-- Whether the app launches in full screen. Optional. Mobile only. Default false -->
            <!-- <fullScreen></fullScreen> -->
            <!-- The render mode for the app (either auto, cpu, gpu, or direct). Optional. Default auto -->
            <!-- <renderMode></renderMode> -->
            <!-- Whether the default direct mode rendering context allocates storage for depth and stencil buffers.  Optional.  Default false. -->
            <!-- <depthAndStencil></depthAndStencil> -->
                        <!-- Whether or not to pan when a soft keyboard is raised or lowered (either "pan" or "none").  Optional.  Defaults "pan." -->
                        <!-- <softKeyboardBehavior></softKeyboardBehavior> -->
                        <!-- Display Resolution for the app (either "standard" or "high"). Optional, OSX-only. Default "standard" -->
                        <!-- <requestedDisplayResolution></requestedDisplayResolution> -->
              <autoOrients>true</autoOrients>
            <fullScreen>false</fullScreen>
            <visible>true</visible>
        </initialWindow>
              <!-- We recommend omitting the supportedProfiles element, -->
              <!-- which in turn permits your application to be deployed to all -->
              <!-- devices supported by AIR. If you wish to restrict deployment -->
              <!-- (i.e., to only mobile devices) then add this element and list -->
              <!-- only the profiles which your application does support. -->
              <!-- <supportedProfiles>desktop extendedDesktop mobileDevice extendedMobileDevice</supportedProfiles> -->
              <!-- Languages supported by application -->
              <!-- Only these languages can be specified -->
              <!-- <supportedLanguages>en de cs es fr it ja ko nl pl pt ru sv tr zh</supportedLanguages> -->
              <!-- The subpath of the standard default installation location to use. Optional. -->
              <!-- <installFolder></installFolder> -->
              <!-- The subpath of the Programs menu to use. (Ignored on operating systems without a Programs menu.) Optional. -->
              <!-- <programMenuFolder></programMenuFolder> -->
              <!-- The icon the system uses for the application. For at least one resolution,
              specify the path to a PNG file included in the AIR package. Optional. -->
              <!-- <icon>
                        <image16x16></image16x16>
                        <image29x29></image29x29>
                        <image32x32></image32x32>
                        <image36x36></image36x36>
                        <image40x40></image40x40>
                        <image48x48></image48x48>
                        <image50x50></image50x50>
                        <image57x57></image57x57>
                        <image58x58></image58x58>
                        <image72x72></image72x72>
                        <image76x76></image76x76>
                        <image80x80></image80x80>
                        <image96x96></image96x96>
                        <image100x100></image100x100>
                        <image114x114></image114x114>
                        <image120x120></image120x120>
                        <image128x128></image128x128>
                        <image144x144></image144x144>
                        <image152x152></image152x152>
                        <image512x512></image512x512>
                        <image732x412></image732x412>
                        <image1024x1024></image1024x1024>
              </icon> -->
              <!-- Whether the application handles the update when a user double-clicks an update version
              of the AIR file (true), or the default AIR application installer handles the update (false).
              Optional. Default false. -->
              <!-- <customUpdateUI></customUpdateUI> -->
              <!-- Whether the application can be launched when the user clicks a link in a web browser.
              Optional. Default false. -->
              <!-- <allowBrowserInvocation></allowBrowserInvocation> -->
              <!-- Listing of file types for which the application can register. Optional. -->
              <!-- <fileTypes> -->
                        <!-- Defines one file type. Optional. -->
                        <!-- <fileType> -->
                                  <!-- The name that the system displays for the registered file type. Required. -->
                                  <!-- <name></name> -->
                                  <!-- The extension to register. Required. -->
                                  <!-- <extension></extension> -->
                                  <!-- The description of the file type. Optional. -->
                                  <!-- <description></description> -->
                                  <!-- The MIME content type. -->
                                  <!-- <contentType></contentType> -->
                                  <!-- The icon to display for the file type. Optional. -->
                                  <!-- <icon>
                                            <image16x16></image16x16>
                                            <image32x32></image32x32>
                                            <image48x48></image48x48>
                                            <image128x128></image128x128>
                                  </icon> -->
                        <!-- </fileType> -->
              <!-- </fileTypes> -->
        <!-- iOS specific capabilities -->
              <!-- <iPhone> -->
                        <!-- A list of plist key/value pairs to be added to the application Info.plist -->
                        <!-- <InfoAdditions>
                <![CDATA[
                    <key>UIDeviceFamily</key>
                    <array>
                        <string>1</string>
                        <string>2</string>
                    </array>
                    <key>UIStatusBarStyle</key>
                    <string>UIStatusBarStyleBlackOpaque</string>
                    <key>UIRequiresPersistentWiFi</key>
                    <string>YES</string>
                ]]>
            </InfoAdditions> -->
            <!-- A list of plist key/value pairs to be added to the application Entitlements.plist -->
                        <!-- <Entitlements>
                <![CDATA[
                    <key>keychain-access-groups</key>
                    <array>
                        <string></string>
                        <string></string>
                    </array>
                ]]>
            </Entitlements> -->
              <!-- Display Resolution for the app (either "standard" or "high"). Optional. Default "standard" -->
              <!-- <requestedDisplayResolution></requestedDisplayResolution> -->
              <!-- Forcing Render Mode CPU for the devices mentioned. Optional  -->
              <!-- <forceCPURenderModeForDevices></forceCPURenderModeForDevices> -->
              <!-- File containing line separated list of external swf paths. These swfs won't be
              packaged inside the application and corresponding stripped swfs will be output in
              externalStrippedSwfs folder. -->
              <!-- <externalSwfs></externalSwfs> -->
              <!-- </iPhone> -->
              <!-- Specify Android specific tags that get passed to AndroidManifest.xml file. -->
        <!--<android> -->
        <!--          <manifestAdditions>
                        <![CDATA[
                                  <manifest android:installLocation="auto">
                                            <uses-permission android:name="android.permission.INTERNET"/>
                                            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
                                            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
                                            <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/>
                                            <application android:enabled="true">
                                                      <activity android:excludeFromRecents="false">
                                                                <intent-filter>
                                                                          <action android:name="android.intent.action.MAIN"/>
                                                                          <category android:name="android.intent.category.LAUNCHER"/>
                                                                </intent-filter>
                                                      </activity>
                                            </application>
                </manifest>
                        ]]>
            </manifestAdditions> -->
                  <!-- Color depth for the app (either "32bit" or "16bit"). Optional. Default 16bit before namespace 3.0, 32bit after -->
            <!-- <colorDepth></colorDepth> -->
            <!-- Indicates if the app contains video or not. Necessary for ordering of video planes with graphics plane, especially in Jellybean - if you app does video this must be set to true - valid values are true or false -->
            <!-- <containsVideo></containsVideo> -->
        <!-- </android> -->
              <!-- End of the schema for adding the android specific tags in AndroidManifest.xml file -->
    <android>
            <manifestAdditions><![CDATA[
                                  <manifest android:installLocation="auto">
                                      <!--See the Adobe AIR documentation for more information about setting Google Android permissions-->
                                      <!--La suppression de l’autorisation android.permission.INTERNET aura comme effet secondaire
                        de vous empêcher de déboguer l’application sur le périphérique.-->
                                      <!--<uses-permission android:name="android.permission.INTERNET"/>-->
                                      <!--<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>-->
                                      <!--<uses-permission android:name="android.permission.READ_PHONE_STATE"/>-->
                                      <!--<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>-->
                                      <!--Les autorisations DISABLE_KEYGUARD et WAKE_LOCK doivent être permutées
                        afin d’accéder aux API SystemIdleMode d’AIR.-->
                                      <!--<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>-->
                                      <!--<uses-permission android:name="android.permission.WAKE_LOCK"/>-->
                                      <!--<uses-permission android:name="android.permission.CAMERA"/>-->
                                      <!--<uses-permission android:name="android.permission.RECORD_AUDIO"/>-->
                                      <!--Les autorisations ACCESS_NETWORK_STATE et ACCESS_WIFI_STATE doivent être
                        permutées afin d’utiliser les API NetworkInfo d’AIR.-->
                                      <!--<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>-->
                                      <!--<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>-->
                                  </manifest>
                        ]]></manifestAdditions>
        </android>
        <iPhone>
            <InfoAdditions><![CDATA[
                                  <key>UIDeviceFamily</key>
                                  <array>
                                            <string>1</string>
                                            <string>2</string>
                                  </array>
                        ]]></InfoAdditions>
            <requestedDisplayResolution>high</requestedDisplayResolution>
        </iPhone>
    </application>

  • Using formats of SO10 text in Adobe forms

    Hello guys,
    I got a question concerning the interaction of SO10 texts with adobe form text fields.
    I know there are some threads about it here, and I think I understand the default SAP behavior, but can you please confirm if I am right? Then I got a special question about one case.
    So is it right that there is only the difference between formatting the textfield itself in adobe form layout and adding a style to the text field in form context?
    This means:
    (1) Whenever in my text field in form context no style is added, the adobe form will take the formatting like it is done in the adobe form layout? This would mean that every format which is entered in the SO10 text is insignificant for the adobe form?
    (2) Whenever in my text field a style is added, SAP will use SO10 text formats? This means, SAP searches for the smartforms style which is entered in the textfield and uses the formats from SO10 text like they were defined in the smartforms style?
    Is this correct so far?
    Now the special questions:
    (1) What happens if a style is added, but the style does not exist as smartforms style. Which font etc. will be used then?
    (2) What happens if a style is added, but the format of SO10 text does not exist in the smartform style?
    In both cases it looks like SAP takes some "default" style, but where does it come from?
    Thanks a lot!
    Regards
    Michael

    Thanks Rakhi, but that did not resolve my issue. Below is new out as per the thread suggestion and this is not what I wanted.:
    "<H>Thank you for choosing Enterprise.</> We look forward to seeing you at 9:00 am on Monday,
    November 28, 2011. This message is to confirm you have updated your reservation.
    Following are the details for the updated reservation:
    P.S. Remember us when you're renting in town. Enterprise is always nearby at more than 6,500
    neighborhood locations."
    - shalini

  • TextField and CSS: How to control spacing between paragraphs

    I'm using an external CSS to format a textField that has some
    HTML text in it, let's say something similar to this:
    myTextField.htmlText = "<p>paragraph
    one</p><p>paragraph two</p>";
    How can I control the spacing between paragraphs when there
    is no support for margin-top or margin-bottom? I don't want to add
    empty <p> or <br /> elements to my text since they
    don't allow exact control and insert too much space. Is there any
    good solution?
    Thanks

    I think rob day's suggestion has merits too. Either way I
    don't see any other way but inserting an extra element that adjusts
    the spacing somehow.
    Yes, it sucks that the majority of styling declarations are
    not supported but, on the other hand, it is not such a big deal to
    insert an element especially with the powerful XML tools in AS3.
    You can create a function that will preprocess all XML "page"
    nodes and insert an extra <p> tag after each <p> tag
    (see attached code)
    I did not check if code works - it is just a concept.
    The same approach can be taken with rob's suggestion but
    inside the <p> element that comes with the XML.

  • Currency format masking

    Is it possible to Mask a textfield numeric entry into locale specific currency
    mormat.
    I have tried it with <netui:formatNumber> tag ,but it is not giving the right
    result.
    Say if i enter 123457678 in a textfield ,it has to be formatted in UK format i.e,1,23,45,678
    How can it be done

    I think you will need to do the formatting in javascript. The formatNumber
    tag does not support the varying number of digits between commas. The
    formatString handles arbitrary string formats but it works left to right and
    so it isn't good for numbers.
    "Mr.Federal" <[email protected]> wrote in message
    news:[email protected]...
    >
    ok
    is it possible to format a number as follows
    1,23,45,67,890.89
    "John Rohrlich" <[email protected]> wrote:
    The problem is that the double has been formatted into a String of the
    form
    $12.34 and this is POSTed back into a double type.Without unformatting
    the $
    off the currency, this won't convert into a Java double type. That's
    why
    type conversion is failing. Unfortunately there is no support to unformat
    this string before POSTing back.
    - john
    "Mr.Federal" <[email protected]> wrote in message
    news:[email protected]...
    Thanks john,
    Can i format a textfield entry using
    <netui:formatNumber country="GB" type="currency" language="en"/>
    I have tried it,but while submitting the page ,it displays the
    following
    error
    []: NetUI Warning: Unable to update expression"{pageFlow.bsImpl.balanceSheet[0][26].amount}".
    The typical cause is that the object represented by the expressionis not
    available
    or is the wrong type for updating. Cause:com.bea.wlw.netui.script.ExpressionUpdateException:
    Exception when attempting to update the expression"{pageFlow.bsImpl.balanceSheet[0][26].amount}"
    with available binding contexts [actionForm, pageFlow, globalApp].Root
    cause:
    com.bea.wlw.netui.script.IllegalExpressionException: The type "double"can
    not
    be set through XScript.
    could u help me to figure it out ?
    "John Rohrlich" <[email protected]> wrote:
    Here is how you can get a UK format for currency but I'm not sure
    if
    that is
    the problem you are trying to solve. Let me know.
    <netui:label value="12345678">
    <netui:formatNumber country="GB" type="currency"language="en"/>
    </netui:label>
    Here is the result
    £12,345,678.00
    - john
    "Mr.Federal" <[email protected]> wrote in message
    news:[email protected]...
    Is it possible to Mask a textfield numeric entry into locale
    specific
    currency
    mormat.
    I have tried it with <netui:formatNumber> tag ,but it is not givingthe
    right
    result.
    Say if i enter 123457678 in a textfield ,it has to be formatted
    in
    UK
    format i.e,1,23,45,678
    How can it be done

  • Embed fonts on classic TextField doesn't work, even with TextFormat applied

    Hi.
    I created an Item that extends MovieClip and that has a TextField on it where it where it will display the item's name. I want to embed the font but I'm having trouble because the text won't display.
    I read the embedFonts description (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.ht ml#embedFonts) and I have formatted the TextField via a TextFormat instance with my chosen font.
    My code:
    import flash.display.MovieClip;
        import flash.text.AntiAliasType;
        import flash.text.TextField;
        import flash.text.TextFieldAutoSize;
        import flash.text.TextFormat;
        public class Item extends MovieClip {
            private var _sName:String = "";
            private var _txtName:TextField = new TextField();
            private var _nColor:uint = 0xAACC00;
            private var _tfText:TextFormat = new TextFormat();
            public function Item(s:String) {
                //also tried embedding here but got the same result
                _txtName.text = s;
                _txtName.autoSize = TextFieldAutoSize.RIGHT;
                _tfText.font = "Helvetica";
                _tfText.size = 30;
                _tfText.color = _nColor;
                _txtName.setTextFormat(_tfText);
                _txtName.antiAliasType = AntiAliasType.ADVANCED;
                _txtName.embedFonts = true;
                addChild(_txtName);
    If I remove the embed part the text shows correctly. I'm at a loss, what order of elements do I need to use to embed the font correctly?
    Thank you.

    To use the embedFonts property you would have to use an actual embedded font. The way you have it coded it is using system fonts.
    I did a quick Google Search and this seems to explain how to embed fonts in AS3 quite well:
    http://divillysausages.com/blog/as3_font_embedding_masterclass

  • Here is my GridBagLayout version of the code

         public void constructGUI()
               c= getContentPane();
              //Construct the menus and their listeners
              JMenu filemenu = new JMenu("File");
              JMenuItem saveas= new JMenuItem ("Save Amortization As");
              saveas.addActionListener(new ActionListener(){
                   public void actionPerformed (ActionEvent e)
                        JFileChooser filechooser = new JFileChooser ();
                        filechooser.setFileSelectionMode ( JFileChooser.FILES_ONLY);
                        int result = filechooser.showSaveDialog (null);
                        if (result== JFileChooser.CANCEL_OPTION)
                             return;
                        File filename = filechooser.getSelectedFile();
                        if (filename==null||filename.getName().equals (" "))
                             JOptionPane.showMessageDialog( null, "Invalid File Name", "Invalid FileName", JOptionPane.ERROR_MESSAGE );
                        else {
                             try
                                  System.out.println("I am ready to create the streams");
                                  FileOutputStream file = new FileOutputStream(filename, true);
                                  OutputStreamWriter filestream = new OutputStreamWriter(new BufferedOutputStream(file));
                                  String info= "The data is based on"+"\n";
                                  filestream.write(info);
                                  System.out.println("I wrote the first string called info");
                                  String interestdata= "INTEREST:"+" "+interest+"\n";
                                  filestream.write(interestdata);
                                  String timedata="The amortization period is:"+" "+time+"\n";
                                  filestream.write(timedata);
                                  String loandata="The money borrowed is:"+" "+moneyFormat.format(loannumber)+"\n";
                                  filestream.write(loandata);
                                  String totals= "Total of Payments Made:"+" " +moneyFormat.format(totalpayments)+"\n"+"Total Interest Paid:"+"  "+moneyFormat.format(totalinterest)+"\n";
                                  filestream.write(totals);
                                  String filestring = "PAYMENT NUMBER"+"   " + "PAYMENT" + "   " + " PRINCIPLE" + "   " + "INTEREST" +"   " + " BALANCE" + "\n";
                                  filestream.write(filestring);
                                  double loannumberkf= loannumber;
                                  System.out.println(timenumber);
                                  for (int j=1; j<=timenumber ; j++ )
                                       double principlekf=payment-loannumberkf*z;
                                       double balancef=loannumberkf-principlekf;
                                       String display ="\n"+ Integer.toString(j)+"                " + moneyFormat.format(payment)+"        "+ moneyFormat.format(principlekf)+ "     "+moneyFormat.format(loannumberkf*z)+ "     "+ moneyFormat.format(balancef)+"\n";
                                       filestream.write(display);
                                       loannumberkf=loannumberkf-principlekf;
                                  filestream.flush();
                                  file.close();
                             catch ( IOException ioException )
                                  JOptionPane.showMessageDialog (null, "File Does not exist", "Invalid File Name", JOptionPane.ERROR_MESSAGE);
                        }//end of else
                 } //end anonymous inner class
              filemenu.add(saveas);
              JMenuItem exit= new JMenuItem ("Exit");
              exit.addActionListener( new ActionListener() {
                        public void actionPerformed (ActionEvent e)
                             System.exit(0);
                   } //end anonymous inner class
              ); // end call to ActionListener
              filemenu.add(exit);
              JMenuItem summaries=new JMenuItem ("Save Summaries As");
              MenuHandler menuhandler= new MenuHandler();
              summaries.addActionListener(menuhandler);
              filemenu.add(summaries);
              //construct the second JMenu
              JMenu colorchooser=new JMenu("Color Chooser");
              JMenuItem colorchooseritem=new JMenuItem("Choose Color");
              colorchooseritem.addActionListener (new ActionListener() {
                                  public void actionPerformed(ActionEvent e)
                                       color=JColorChooser.showDialog(Mortgagecalculation.this, "Choose a Color", color);
                                       c.setBackground(color);
                                       c.repaint();
                         ); //end of registration
              colorchooser.add(colorchooseritem);
              //third menu
              JMenu service = new JMenu("Services");
              JMenuItem s1= new JMenuItem ("Display Amortization");
              JMenuItem s2= new JMenuItem ("Calender");
              service.add(s1);
              service.add(s2);
              //Create menu bar and add the two JMenu objects
              JMenuBar menubar = new JMenuBar();
              setJMenuBar(menubar);
              menubar.add(filemenu); // end of menu construction
              menubar.add(colorchooser);
              menubar.add(service);
              //set the layout manager for the JFrame
              gbLayout = new GridBagLayout();
              c.setLayout(gbLayout);
              gbConstraints = new GridBagConstraints();
              //construct table and place it on the North part of the Frame
              JLabel tablelabel=new JLabel ("The Table below displays amortization values after you press O.K. on the payments window. Payments window appears after you enter the values for rate, period and loan");
              mydefaulttable = new DefaultTableModel();
                   mydefaulttable.addColumn("PAYMENT NUMBER");
                   mydefaulttable.addColumn ("PAYMENT AMOUNT");
                   mydefaulttable.addColumn ("PRINCIPLE");
                   mydefaulttable.addColumn ("INTEREST");
                   mydefaulttable.addColumn("LOAN BALANCE");
              Box tablebox=Box.createVerticalBox();   
              mytable=new JTable(mydefaulttable);
              tablelabel.setLabelFor(mytable);
              JScrollPane myscrollpane= new JScrollPane (mytable);
              tablebox.add(tablelabel);
              tablebox.add(myscrollpane);
              //gbConstraints.weightx = 100;
              //gbConstraints.weighty = 50;
              //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.NORTH;
              addComponent(tablebox,0,0,3,1,GridBagConstraints.NORTH);
            //c.add (tablebox, BorderLayout.NORTH);
              //create center panel
              JLabel panellabel=new JLabel("Summarries");
              MyPanel panel =new MyPanel();
              panel.setSize (10, 50);
              panel.setBackground(Color.red);
              panellabel.setLabelFor(panel);
              Box panelbox=Box.createVerticalBox();
              panelbox.add(panellabel);
              panelbox.add(panel);
              //gbConstraints.weightx = 50;
              //gbConstraints.weighty = 100;
            //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.CENTER;
              addComponent(panelbox,1,1,1,1,GridBagConstraints.CENTER);
              //c.add (panelbox, BorderLayout.CENTER);
              //add time in the SOUTH part of the Frame
              Panel southpanel=new Panel();
              southpanel.setBackground(Color.magenta);
              Date time=new Date();
              String timestring=DateFormat.getDateTimeInstance().format(time);
              TextField timefield=new TextField("The Date and Time in Chicago is:"+" "+timestring, 50);
              southpanel.add(timefield);
              //gbConstraints.weightx = 100;
              //gbConstraints.weighty = 1;
              //gbConstraints.fill = GridBagConstraints.HORIZONTAL;
              gbConstraints.anchor = GridBagConstraints.SOUTH;
              addComponent(southpanel,0,2,3,1,GridBagConstraints.SOUTH);
              //c.add(southpanel, BorderLayout.SOUTH);
              //USE "BOX LAYOUT MANAGER" TO ARRANGE COMPONENTS LEFT TO RIGHT WITHIN THE SOUTH PART OF THE FRAME
              //Create a text area to output more information about the application.Place it in a box and place box EAST
              Font f=new Font("Serif", Font.ITALIC+Font.BOLD, 16);
              string="-If you would like to exit this program\n"+
              "-click on the exit menu item \n"+
                   "-if you would like to save the table as a text file \n"+
                   "-click on Save As menu item \n"+"-You can reenter new values for calculation\n"+
                   " as many times as you would like.\n"+
                   "-You can save the summaries also on a different file\n"+
                   "-Files are appended";
              JLabel infolabel= new JLabel ("Information About this Application", JLabel.RIGHT);
              JTextArea textarea=new JTextArea(25,25);
              textarea.setFont(f);
              textarea.append(string);
              infolabel.setLabelFor(textarea);
              Box box =Box.createVerticalBox();
              box.add(infolabel);
              box.add(new JScrollPane (textarea));
              //gbConstraints.weightx = 50;
              //gbConstraints.weighty = 100;
              //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.SOUTHEAST;
              addComponent(box,2,1,1,1,GridBagConstraints.SOUTHEAST);
              //c.add(box, BorderLayout.EAST);
              //Create the text fields for entering data and place them in a box WEST
              Panel panelwest = new Panel();
              //create the first panelwest and place the text fields in it
              Box box1=Box.createVerticalBox();
              JLabel rate= new JLabel ("Enter Rate", JLabel.RIGHT);
              interestfield=new JTextField ("Enter Interest here and press Enter", 15);
              rate.setLabelFor(interestfield);
              box1.add(rate);
              box1.add(interestfield);
              JLabel period=new JLabel("Enter Amortization Periods", JLabel.RIGHT);
              timenumberfield=new JTextField("Enter amortization period in months and press Enter", 15);
              period.setLabelFor(timenumberfield);
              box1.add(period);
              box1.add(timenumberfield);
              JLabel loan=new JLabel("Enter Present Value of Loan", JLabel.RIGHT);
              loanamountfield =new JTextField ("Enter amount of loan and press Enter", 15);
              loan.setLabelFor(loanamountfield);
              box1.add(loan);
              box1.add(loanamountfield);
              JLabel submit = new JLabel("Press Submit Button to Calculate", JLabel.RIGHT);
              submitbutton= new JButton("SUBMIT");
              submit.setLabelFor(submitbutton);
              box1.add(submit);
              box1.add(submitbutton);
              panelwest.add(box1);
              //Add the panel to the content pane
              //gbConstraints.weightx = 50;
              //gbConstraints.weighty = 100;
              //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.SOUTHWEST;
              addComponent(panelwest,0,1,1,1,GridBagConstraints.SOUTHWEST);
              //c.add(panelwest, BorderLayout.WEST);
              //Event handler registration for text fields and submit button
              TextFieldHandler handler=new TextFieldHandler();
              interestfield.addActionListener(handler);
              timenumberfield.addActionListener(handler);
              loanamountfield.addActionListener(handler);
              submitbutton.addActionListener(handler);
              setSize(1000, 700);   
              setVisible(true);
              System.out.println("repainting table, constructor");
              System.out.println("I finished repainting. End of ConstructGUI");
         } // END OF CONSTUCTGUI
         // addComponent() is developed here
         private void addComponent(Component com,int row,int column,int width,int height,int ancor)
              //set gridx and gridy
              gbConstraints.gridx = column;
              gbConstraints.gridy = row;
              //set gridwidth and gridheight
              gbConstraints.gridwidth = width;
              gbConstraints.gridheight = height;
              gbConstraints.anchor = ancor;
              //set constraints
              gbLayout.setConstraints(com,gbConstraints);
              c.add(com);          
         

    Quit cross-posting (in different forums) every time you have a question.
    Quit multi-posting (asking the same questions twice) when you ask a question.
    Start responding to your old questions indicating whether the answers you have been given have been helpfull or not.
    Read the tutorial before asking a question. Start with [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use GridBag Layout. Of course its the most difficult Layout Manager to master so I would recommend you use various combinations of the other layout managers to achieve your desired results.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • URL in plugins

    I want to access the record url of a lookup field in plugin and have to put into one URL field.So that If I click on that URL text the user should directly move to that particular record.
    Can we achieve this functionality in plugin?Please let me know the solution or work around ASAP...its urgent.
    Prashant Wani
    Prashant Wani ,Software Engineer-II,Infinx Services Pvt.Ltd.

    Hi Prashant,
    Do you mean you want to generate the URL of the look up record and set into text field so that user should be able to open record directly?
    You can achieve it through JS as well.
    - In below url dynamically set the entity type and Id of the record. Construct the URL. You can read the Server URL,Entity type and Id of lookup and construct the URl.
    https://URL/main.aspx?etn=incident&pagetype=entityrecord&id=%7BE08FE768-325F-E311-93F3-00155D10120B%7D.
    - Set the constructed URL into text field.
    If you are using CRm 2013 we have new URl format of String type field available. if you are using CRM 2011 you can dynamically make it hyperlink. refer below link.
    https://community.dynamics.com/crm/b/mshelp/archive/2013/02/15/crm-2011-change-format-of-textfield-to-hyperlink.aspx
    Thanks!
    Kalim Khan

  • Problem with TextField formatting

    I'm having a little bit of a problem with this very basic bit
    of code. The following code works fine: (I apologize for not having
    it in a format that may be more suitable)
    this.createTextField("my_text", this.getNextHighestDepth(),
    10, 70, 400, 100);
    my_text.text = "This is my TextField.";
    //my_text.embedFonts = true;
    However, for some reason, this doesn't work. I'm baffled by
    why uncommenting this simple line of code makes it not show up:
    this.createTextField("my_text", this.getNextHighestDepth(),
    10, 70, 400, 100);
    my_text.text = "This is my TextField.";
    my_text.embedFonts = true;
    Any help would be appreciated.

    My guess is that you forgot a few things to work with
    embedded fonts...
    1) Have you embedded the font you want to use inside your
    library and given it a unique id.
    2) If you did #1, try this...

  • IR - 9.2 - how to format a number to a textfield in dashboard

    Hello,
    i am going to develop an individual Dashboard with free positionung textfields, almost all works, but how can i formatting the numbers?
    here the script:
    var Ausfall=ActiveDocument.Sections["Ergebnisse"].Columns["Ausfall"].GetCell(1);
    var AB=ActiveDocument.Sections["Ergebnisse"].Columns["A B"].GetCell(1);
    var ABprozw=AB/Ausfall;
    AnzeigeABProz.Text=ABprozw; /* is a free positioning textfield in dashboard */
    in the dashboard ist the value shown as
    0.7793775542282301
    but how can i get a number format as:
    0,78
    or
    78,9%
    are there any convert/formating function (to dashboard-textfields) in IR ?
    mfg
    Jens Rohloff

    If you want the Percent signt o show up then you will need to treat the number as a string.
    Another option
    var ABprozw=AB/Ausfall * 100;
    var ABprozw = Math.round(ABprozw)
    var ABprozw = ABprozw/100
    This will give you tne 0.78
    Wayne Van Sluys
    TopDown Consulting

  • Scan textfield for keyword and apply formatting

    I was interested in searching through text in a textfield, and applying text formatting to keywords. For example, every time the word 'the' appears, apply a text format that changes it to green and 14pt. Here is an example of a format and text applied to a textfield. How would I go about searching through the textfield and applying this format only to specific words?
    my_txt.text = 'The cat jumped over the house.'
    /// my format I want to apply
    with (_lt_fmt) {
                    align = 'left';
                    blockIndent = 0;
                    bold = false;
                    bullet = false;
                    color = _green;
                    font = FontNames.ARIAL;
                    indent = 0;
                    italic = false;
                    kerning = false;
                    leading = 0;
                    leftMargin = 0;
                    letterSpacing = 0;
                    rightMargin = 0;
                    size = 14;
                    tabStops = [];
                    target = "";
                    underline = false;
                    url = "";

    " I replaced some var names b/c they were reserved words"
    There were no reserved words for the current or application scope.
    "How can I keep all the words highlighted in the different formats?"
    Comment out this line:
    main_txt.setTextFormat(main_txt.defaultTextFormat);
    Also, the code you showed is too verbose. You can combine declarations and and instantiation in one place and have 5 lines instead of 10:
    var highLightFormat0:TextFormat = new TextFormat("Arial",14,0xff00ff,"bold");
    var highLightFormat1:TextFormat = new TextFormat("Arial",7,0xff0000,"bold");
    var highLightFormat2:TextFormat = new TextFormat("Arial",9,0xCCCCCC,"bold");
    var highLightFormat3:TextFormat = new TextFormat("Arial", 8, 0xffEE00, "bold");
    var main_txt:TextField = new TextField();
    In addition, function  getTxtFmt and the way you deal with getting TExtFormats is an ovekill - conditionals are worse than direct references. So, I suggest your code is:
    import flash.text.TextFormat;
    // keywords to highlight
    var wordsToSearch:Vector.<String> = new <String>['the','interested','text', 'applying'];
    // TxtFormats
    var highLightFormats:Vector.<TextFormat> = new <TextFormat>[new TextFormat("Arial", 14, 0xff00ff, "bold"), new TextFormat("Arial", 7, 0xff0000, "bold"), new TextFormat("Arial", 9, 0xCCCCCC, "bold"), new TextFormat("Arial", 8, 0xffEE00, "bold")];
    // Create TextField and add to display list
    var main_txt:TextField = new TextField();
    with (main_txt) {
         multiline = main_txt.wordWrap = true;
         autoSize = "left";
         width = 400;
         defaultTextFormat = new TextFormat("Arial",12);
         x = main_txt.y = 20;
         text = "I was interested in searching through text in a textfield, and applying text formatting to keywords. For example, every time the word 'the' appears, apply a text format that changes it to green and 14pt. Here is an example of a format and text applied to a textfield. How would I go about searching through the textfield and applying this format only to specific words?";
    addChild(main_txt);
    // Iterate through Vector of keywords
    for (var i:int; i < wordsToSearch.length; i++){
         search(wordsToSearch[i], i);
    // find whole words
    function search(keyword:String, fmtChoice:int):void {
         //main_txt.setTextFormat(main_txt.defaultTextFormat);
         var txt:String = main_txt.text;
         var pattern:RegExp = new RegExp("\(\?\<\=\\s)" + keyword + "\\s","ig");
         var theResult:Object = pattern.exec(txt);
         while (theResult) {
              main_txt.setTextFormat( highLightFormats[fmtChoice], theResult.index, theResult.index + keyword.length);
              theResult = pattern.exec(txt);

  • HtmlText Auto formatting textfield

    how could we remove auto tag adding by htmlText Property because when we apply htmlText for a textfield it automatically add <p> and <font> tag.
    In my project i am saving one textfield property <p align='right'> in server but when i am assigning this value from server its changing to <p align='left'>.
    So how could we remove this auto formatting by htmlText??
    As in http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html link there is written also "When its htmlText property is traced, the output is the HTML-formatted String, with additional tags (such as <P> and <FONT>) automatically added by Flash Player."
    i want to remove this auto adding tag. Please help me out.

    Hy thanks K for so fast reply,
         No, i am basically making an editor kind of thing, where some text have align=left property and some have align=right property. So while saving i am checking alignment of the text and applying in <p> tag. Suppose i saved <p align="right">Text Sample</p> now i called this string from server and applied to my TextField. Now when i am assigning this text to textfield (mytext.htmlText = someServerVariable) then its coming as <p align="left">Text Sample</p>.
    Some tags of font is also there which i ignored here. i just want to put same string in html text. i want to remove auto formatting property of htmlText.

Maybe you are looking for