TextField Listener

Hi there!
How could I buil an efficient TextField Listener?
I unsuccessfully tried different solutions based on
onScroller and onChanged...
Flash Help is not very newbie friendly...
onScroller seems to be the best solution because it can be
triggered by AS but the Listener I built isn't working.
Many thanks in advance for your help.
Best regards,
Gerry

use the onChanged handler and watch function (for the
textfield's text property). the first detects changes to input
textfields via user interaction and the 2nd detects changes due to
a.s.

Similar Messages

  • URGENT HELP NEEDED Shmoove  !!!!!!!!!!!!!!!!!!!!!!!

    I have developed an application which has one Midlet & a .txt file(437 KB , 12276 RECORDS ) .due to large size of my text file my application is getting very slow nearly after 700 records .what should i do?
    Following is my code:
    import net.jscience.util.MathFP;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.lang.*;
    import java.util.*;
    import java.io.*;
    public class MyTest extends MIDlet implements CommandListener
    private Display display;     // Reference to Display object
    private Form fmMain; // Main form
    private Command cmTest; // Get contents of textfield
    private Command cmExit;          // Command to exit the MIDlet
    private Command cmStart;
    private Command cmPremium;
    private TextField tfAge; // Textfield
    private TextField tfPolicy;
    private TextField tfTerm1;
    private TextField tfTerm2;
    private TextField tfSummAss;
    String r1;
    String r2;
    String r3;
    String r4;
    String r5;
    public MyTest()
    display = Display.getDisplay(this);
    // Create commands
    cmTest = new Command("Get Contents", Command.SCREEN, 1);
    cmExit = new Command("Exit", Command.EXIT, 1);
    cmStart=new Command("Start",Command.OK,1);
    cmPremium=new Command("Premium",Command.OK,1);
         String s1 = "";
         String s2 = "";
    // Textfield for numbers entry
    tfAge = new TextField("Age:", s1, 10, TextField.ANY);
    tfPolicy = new TextField("Policy No:", s2, 10, TextField.ANY);
    tfTerm1 = new TextField("Term1:", s2, 10, TextField.ANY);
    tfTerm2 = new TextField("Term2:", s2, 10, TextField.ANY);
    // Create Form, add Commands and textfield, listen for events
    fmMain = new Form("Enter Numbers");
    fmMain.addCommand(cmExit);
    fmMain.addCommand(cmStart);
    fmMain.addCommand(cmPremium);
    fmMain.addCommand(cmTest);
    fmMain.append(tfAge);
    fmMain.append(tfPolicy);
    fmMain.append(tfTerm1);
    fmMain.append(tfTerm2);
    fmMain.setCommandListener(this);
    // Called by application manager to start the MIDlet.
    public void startApp()
         display.setCurrent(fmMain);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command c, Displayable s)
    if (c == cmTest)
    System.out.println("TextField contains: " + tfAge.getString());
    System.out.println("MathFP Test: " +(MathFP.toString(MathFP.toFP(76))));
    else if (c == cmStart)
              r1=tfAge.getString();
              int t1 = MathFP.toFP(r1);
              System.out.println("MathFP Test1: " + (MathFP.toString(t1)));
              r2 = tfPolicy.getString();
              int t2 = MathFP.toFP(r2);
              Alert al = new Alert("YOUR PREMIUM "," YOUR PREMIUM IS = "+ MathFP.toString(t1,2), null, null);//Show the result
              al.setTimeout(Alert.FOREVER);
              al.setType(AlertType.ERROR);
              display.setCurrent(al);
         else if(c==cmPremium)
              StringBuffer buffer = new StringBuffer();
              String str[] = new String[50];
              int j=0;
              r1=tfAge.getString();
              r2=tfPolicy.getString();
              r3=tfTerm1.getString();
              r4=tfTerm2.getString();
              int t1=Integer.parseInt(r1);
              str[j]="";
              String age="";
              String table="";
              String term1="";
              String term2="";
              String premium="";
              InputStream in = this.getClass().getResourceAsStream("/manish.txt");
              try
                   int i = in.read();
                   while (i != -1 && j<11)
                        str[j]+=(char)i;
                        if(i=='\t')
                             j++;
                             str[j]="";
                             if(i=='\n')
                                  for(int k=0;k<11;k++)
                                       age = str[0].trim();
                                       table = str[1].trim();
                                       term1 = str[3].trim();
                                       term2 = str[4].trim();
                                       premium = str[5].trim();
                                  if(r1.equals(age)==true && r2.equals(table)==true && r3.equals(term1)==true && r4.equals(term2)==true)
                                       Alert box = new Alert("YOUR PREMIUM "," YOUR PREMIUM IS = "+ premium, null, null);
                                       box.setTimeout(Alert.FOREVER);
                                       box.setType(AlertType.ERROR);
                                       display.setCurrent(box);
                                       break;
                                  str[0]="";
                                  j=0;
                        i = in.read();
                   in.close();
                   catch (IOException e)
                        System.out.println(e);
    else if(c == cmExit)
    destroyApp(false);
    notifyDestroyed();

    What can I say, what you're trying to do is a heavy operation and it will slow down the phone no matter what. There are some things you can do to speed things up a little bit, but I doubt they will have a very serious effect on the speed:
    a) You are reading the InputStream one byte at a time. Try restructuring you're code to read into a byte array chunks of the stream (read(byte[] arr, int offset, int length) method).
    b) This one might be the most important. You are creating and destroying a LOT of String objects during those loops. That is creating a LOT of garbage and I imagine the garbage collector starts working overtime (after 700 records like you said), and seriously slowing you down. Try changing that code into using only StringBuffers instead of Strings (and make you're StringBuffers large enough), so that less garbage is created.
    Other than that, I don't know if you're targetting any specific device, but a most of the current devices (except for a few high-end devices) won't have enough heap memory to handle so much data. Not to mention jar size constraints. So it might not be realistic to hope that the phone handle that processing. If it's possible, what I would do is offload all of that premium calculating to a server and use http to get the result from it.
    shmoove

  • KeyboardListener in AS3.0

    hi
    I am facing the problem in the keyboardListener i.e when
    ever i typed the number like 123
    1) when i typed the number 1 it'll display empty
    2) if i typed the number 2 then it display the trace 1.
    can any one help to display when i typed the number in the
    text
    here i am paste my code
    Text_txt.addEventListener(TextEvent.TEXT_INPUT,keyboardlistener)
    function keyboardlistener(e:TextEvent)
    trace(e.target.text)

    that's not a keyboard listener. it's a textfield listener.
    and if you want the text property of your textfield AFTER it's been
    changed use the CHANGE Event, not the TextEvent.TEXT_INPUT which is
    dispatched before the change.

  • Datagram Connection in P800?????

    Hello
    I'm trying to make an UDP Connection from a P800 mobile.
    I know that the Nokia phones only supports HTTP connection, I am trying to do it in Sony Ericsson.
    If finally the P800 doesn't support UDP neither TCP connection.
    Can anyone tell me which mobile support UDP and TCP?
    Thanks in advance
    Hector
    My source code is the following. Please check it if maybe I have made something wrong:
    package datagramtest;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    * <p>Title: </p>
    � * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class Displayable1 extends Form implements CommandListener {
    public TextField inicioText = null; //our TextField to show the incoming chars
    public TextField datagSrvListText = null;
    public TextField listeningText = null;
    public TextField exceptionText = null;
    public TextField finText = null; //and to write the text that must be sent
    private String sDatagram = "datagram://:9000";
    // private String sDatagram = "datagram://http://www.webyu.com:9000";
    // Max datagram size.
    private static final int MAX_DATAGRAM_SIZE = 1500;
    /**Construct the displayable*/
    public Displayable1() {
    super("Main Window - BattleShip v 0.1");
    inicioText = new TextField("Inicio","",200,TextField.ANY);
    datagSrvListText = new TextField("datagram server listener:","",200,TextField.ANY);
    listeningText = new TextField("listening:","",100,TextField.ANY);
    finText = new TextField("Fin","",200,TextField.ANY);
    exceptionText = new TextField("Exception","",200,TextField.ANY);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception {
    // set up this Displayable to listen to command events
    setCommandListener(this);
    // add the Exit command
    addCommand(new Command("Exit", Command.EXIT, 1));
    addCommand(new Command("Init", Command.ITEM, 1));
    this.append(inicioText);
    this.append(datagSrvListText);
    this.append(listeningText);
    this.append(finText);
    this.append(exceptionText);
    /**Handle command events*/
    public void commandAction(Command command, Displayable displayable) {
    /** @todo Add command handling code */
    if (command.getCommandType() == Command.EXIT) {
    // stop the MIDlet
    MIDletMainShip.quitApp();
    if (command.getCommandType() == Command.ITEM)
    connect();
    public void connect()
    boolean isConnectionOK = true;
    // *********** DIFERENTES MENSAJES ******************
    this.inicioText.setString("conectando a " + sDatagram);
    try {
    // Create a new datagram socket.
    DatagramConnection dc =
    (DatagramConnection)Connector.open(sDatagram);
    System.out.println("SYSTEM, datagram server listener: " + sDatagram);
    this.datagSrvListText.setString(sDatagram);
    System.out.println("SYSTEM, datagram size:"+MAX_DATAGRAM_SIZE);
    //this.debugText.setString("datagram size:"+MAX_DATAGRAM_SIZE+"\n");
    Datagram datagram =
    dc.newDatagram(MAX_DATAGRAM_SIZE);
    System.out.println("SYSTEM, listening!");
    this.listeningText.setString("OK!");
    /* dc.receive(datagram);
    System.out.println("SYSTEM, packet revceived!");
    this.debugText.setString("packet revceived!!\n");
    } catch (Exception ex)
    isConnectionOK = false;
    System.out.println("SYSTEM, ex.getMessage() = " + ex.getMessage() );
    System.out.println("SYSTEM, exception raised:");
    this.exceptionText.setString( ex.getMessage() );
    ex.printStackTrace();
    if ( isConnectionOK )
    this.finText.setString("Finalizado con exito!");
    else
    this.finText.setString("Error!");
    public void supportedProtocols()
    boolean isConnectionOK = true;
    // *********** DIFERENTES MENSAJES ******************
    this.inicioText.setString("loading supported protocols");
    try {
    // Create a new datagram socket.
    DatagramConnection dc =
    (DatagramConnection)Connector.open(sDatagram);
    System.out.println("SYSTEM, datagram server listener: " + sDatagram);
    this.datagSrvListText.setString(sDatagram);
    System.out.println("SYSTEM, datagram size:"+MAX_DATAGRAM_SIZE);
    //this.debugText.setString("datagram size:"+MAX_DATAGRAM_SIZE+"\n");
    Datagram datagram =
    dc.newDatagram(MAX_DATAGRAM_SIZE);
    System.out.println("SYSTEM, listening!");
    this.listeningText.setString("OK!");
    /* dc.receive(datagram);
    System.out.println("SYSTEM, packet revceived!");
    this.debugText.setString("packet revceived!!\n");
    } catch (Exception ex)
    isConnectionOK = false;
    System.out.println("SYSTEM, ex.getMessage() = " + ex.getMessage() );
    System.out.println("SYSTEM, exception raised:");
    this.exceptionText.setString( ex.getMessage() );
    ex.printStackTrace();
    if ( isConnectionOK )
    this.finText.setString("Finalizado con exito!");
    else
    this.finText.setString("Error!");

    for a list of MIDP2 phones, available or coming, I recommend that you start with this list:
    http://www.benhui.net/midp2phonelist.html
    btw, do not forget that the MIDP2 specs do not mandate TCP/IP sockets, it only defines the API for those manufacturers that want to support it. Therefore, a device that is MIDP2 compliant may not support MIDP2.
    It looks like that as of today, most devices that support MIDP2 also support TCP/IP sockets.
    serge

  • Key Listening without a textfield or similar

    Ok, I want to let the program call a method when a key is pressed, but so for I have only been able to do this when i added a KeyListener to an object like a textfield.
    You can imagine this is a little bit annoying. I want something that listens to my Keys without some field. A panel was quite hard to implement and then I read something about ProcessKeyEvent and if you want this to work you have to do SOMETHING with enableEvent(), but I have no idea what. Can anybody tell me plz or give me another solution to this problem.

    I think JComponents can listen for KeyEvents (as a previous post explains, there should at least be some component available to listen for the events)
    The code below works for my JTree based component.
    tree.addKeyListener( new HierarchyTreeKeyListener(this) );Where the listener class looks like...
         class HierarchyTreeKeyListener extends KeyAdapter{
              HierarchyTree tree;
              public HierarchyTreeKeyListener(CTree treeIn){
                   tree = treeIn;
              public void keyTyped(KeyEvent kt){
                   //get a handle on the selected node. This will be the root for the search
                   DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
                   //System.out.println("selected node: "+selectedNode);
                   char key = Character.toLowerCase(kt.getKeyChar());
                   boolean found = false;
                        DefaultMutableTreeNode queryNode = (DefaultMutableTreeNode)tree.charSearch(key, selectedNode);
                        if( queryNode != null ){
                             expandPath( queryNode );
              }//end of method
         }//end of class HierarchyTreeKeyListener

  • Listening for changes in dynamic textField

    Hi!
    Been wrestling with this for a while now, and tried to ask for advice, but can't seem to formulate the question right...
    So, as the title says.....
    Can I do this? The textfield is being updated as a user clicks the buttons of a sprite array menu, so that the label names of timeline frames appear in the field. However, I want to be able to click these labelnames also, as they appear in this textfield. The textfield is placed just to the right of the menu, to offer shortcuts to visited menu items. I am not trying to populate a textfield with ton of text in authortime, and then clicking some of it - That is not what I am trying to do.
    Please help!!!

    I guess following code will help you.
    var label:TextField;
    label = new TextField();
    label.type = TextFieldType.DYNAMIC;
    label.selectable = true;
    label.autoSize = TextFieldAutoSize.LEFT;
    label.background = true;
    label.border = true;
    label.multiline = true;
    var format:TextFormat = new TextFormat();
    format.font = "Verdana";
    format.color = 0xFF0000;
    format.size = 10;
    format.underline = true;
    label.defaultTextFormat = format;
    label.height = 20;
    label.width = 60;
    label.x = 10;
    label.y = 20;
    addChild(label);
    label.text = "MENU 1";
    label.appendText("\nMENU 2");
    label.addEventListener(MouseEvent.CLICK, printCursorPosition);
    button.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function printCursorPosition(event:MouseEvent):void {
                var tf:TextField = TextField(event.target);
                trace("caretIndex:", tf.caretIndex);
                trace("selectionBeginIndex:", tf.selectionBeginIndex);
                trace("selectionEndIndex:", tf.selectionEndIndex);
    function mouseDownHandler(event:MouseEvent):void {
                label.appendText("\nClicked");

  • Listener beforeshow on textfield

    Good afternoun,
    I have a question about dialog listeners.
    I have this widget definition inside of my dialog:
         <vanity
                jcr:primaryType="cq:Widget"
                collapsed="{Boolean}true"
                collapsible="{Boolean}true"
                title="Vanity URL"
                xtype="dialogfieldset">
                <items jcr:primaryType="cq:WidgetCollection">
                    <vanityPath
                        jcr:primaryType="cq:Widget"
                        cls="cq-propsdialog-vanityurl"
                        fieldLabel="Vanity URL"
                        xtype="textfield">
                        <listeners
                                  jcr:primaryType="nt:unstructured"
                                  loadcontent="function(field, record, path){VanityPath.loadPath(field);}"
                       beforeshow="function(field){VanityPath.loadPath(field)}"
                                  beforestatesave="function(field, state){VanityPath.copyResult(field);}"/>
                    </vanityPath>
                    <vanityPathFinal
                        jcr:primaryType="cq:Widget"
                        name="./sling:vanityPath"
                        xtype="textfield"/>
                    <vanityPathRedirect
                        jcr:primaryType="cq:Widget"
                        fieldLabel="Redirect Vanity URL"
                        name="./sling:redirect"
                        type="checkbox"
                        xtype="selection"/>
                </items>
            </vanity>
    The beforeshow is not working and I cannot find what is the right definition.
    Thank you for the help.

    The reason may be the "VanityPath" is undefined at the time "beforeshow" event gets called.
    It's better if you add console.log  as follows:
                      function(field){
                      console.log(VanityPath);
                      VanityPath.loadPath(field);
    and check console output.

  • TextField Document listener

    Hello, I have a JTextField and I have created a DocumentListener because I don't want to allow user to insert too many characters.
    When he does, I get this exception "Attempt to mutate in notification". Could anyone help me? My code is this one:
        public class MyListener implements DocumentListener
            public void insertUpdate(DocumentEvent ev)
                Document doc=(Document)ev.getDocument();           
                if(isTooLong()==true)
                    try
                        doc.remove(ev.getOffset(),ev.getLength());
                    catch(Exception e)
                        System.out.println("Error " + e.getMessage());
                        System.exit(0);
            public void removeUpdate(DocumentEvent e)
            public void changedUpdate(DocumentEvent e) {
        }

    I get this exception "Attempt to mutate in notification". You can't update the Document from a DocumentListener.
    The latest recommendation on how to do this is to use a DocumentFilter. An exaple can be found in the Swing tutorial on "Using Text Components":
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

  • ProLoader and TLF TextFields do not work together!

    I'm using ProLoader to load a .swf that uses TLF.  The master .swf loads the target .swf and all code executes as expected with one minor glitch: the content of the loader is white/blank.  Has anyone else seen this!?
    ~~~~~~~~~~~~~~~~~~~~~~~~
    Here is the full bug report that I tried to send Adobe, but they cap reports at 2000 characters and provide no option for uploading a source .zip. (Seriously, Adobe?)  If you have time, and follow my instructions you will see how ProLoader won't even load a .swf with TLF on its stage.  (Yes, I realize this different from my problem, but I'd like to demonostrate how buggy and inconsistent ProLoader is.  The simple solution would be not to use TLF, and mostly likely, I will end up doing that.)
    ******BUG******
    ProLoader loads .swf with TLF, but ProLoader is blank.
    Steps to reproduce bug:
    1.  Download sample files (http://helpx.adobe.com/content/dam/kb/en/141/tn_14190/attachments/Load_External_SWF.zip) from the Tech Note, Load external SWF into another SWF (http://helpx.adobe.com/flash/kb/load-external-swf-swf.html).
    2.  Open ExternalSWF.fla and assign it a document class.
    Here is mine:
    package  {
              import flash.display.MovieClip;
               import flash.events.Event;
              public class ExternalSWF extends MovieClip {
                        public static var DATA_LOAD_COMPLETE:String = "ExternalSWF_DataLoadComplete";
                        private var data_:String;
                        public function ExternalSWF() {}
                        //This function will be called from the .swf that loaded me.
                        public function loadData(data:String):void
                                  data_ = data;
                                  dispatchEvent(new Event(DATA_LOAD_COMPLETE));
                        public function get data():String { return data_; }
    3.  On ExternalSWF.fla's stage, change a classic TextFields into a TLF TextField.
    4.  In Loader_Movie.fla, change all flash.display.Loader instances to fl.display.ProLoader in order to load TLF TextFields.  Also, add an event listener to myLoader for Event.COMPLETE.  Here are my Loader_Movie.fla's Actions:
    import flash.events.Event;
    import fl.display.ProLoader;
    var myLoader:ProLoader = new ProLoader();                     // create a new instance of the ProLoader class
    var url:URLRequest = new URLRequest("ExternalSWF.swf"); // in this case both SWFs are in the same folder
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myLoaderIsLoaded);
    myLoader.load(url);                                     // load the SWF file
    addChild(myLoader);                                     // add that instance to the display list, adding it to the Stage at 0,0
    myLoader.x = 10;                                        // move the loaded SWF 10 pixels to the right (from the left edge)  
    myLoader.y = 175;                                       // move the loaded SWF 175 pixels down from the top
    // (optional) load a second external SWF file
    var my2ndLoader:ProLoader = new ProLoader();
    var url2:URLRequest = new URLRequest("ExternalSWF2.swf");
    my2ndLoader.load(url2);
    addChild(my2ndLoader);                                  // optionally, you could put the 2nd SWF beneath
                                                            // the 1st by using addChildAt(my2ndLoader, 1);
    // (optional) scaling of the 2nd SWF file
    my2ndLoader.scaleX = 2;                                 // scale the SWF horizontally by 200%
    my2ndLoader.scaleY = 2;                                 // scale the SWF vertically by 200%
    function myLoaderIsLoaded(event:Event):void
              trace("The first .swf has loaded so add event listeners");
              var swf:ExternalSWF = ExternalSWF(myLoader.content);
              swf.addEventListener(ExternalSWF.DATA_LOAD_COMPLETE, allFinished);
              swf.loadData("foobar");
    function allFinished(event:Event):void
              trace("Here is the data we loaded: " + ExternalSWF(myLoader.content).data);
    Results:
    [Trace] Output
    ReferenceError: Error #1056: Cannot create property __id0_ on ExternalSWF.
              at flash.display::Sprite/constructChildren()
              at flash.display::Sprite()
              at flash.display::MovieClip()
              at ExternalSWF()
    ExternalSWF is invisible; 4 loading dots appear instead.
    Expected results:
    Both .swfs load without incident.
    Trace output:
    The first .swf has loaded so add event listeners
    Here is the data we loaded: foobar
    Additional notes:
    I discovered this bug when my main/master .swf used ProLoader to load another .swf (with TLF on a symbol in the libary).  In this case, the ProLoader appeared blank/white, not even the 4 loading dots.  However, all the code in both .swfs still ran as expected (shown via the Output panel dumping all expected trace statements until execution finished).
    Environment:
    Adobe FLash Professional CS5.5, Version 11.5.1.349
    (bug discovered while running "Test Movie" in IDE)
    Windows 7 Professional Service Pack 1
    Intel(R) Core(TM)2 Duo CPU  E4600 @ 2.40GHz  2.39 GHz
    RAM: 6.00 GB
    64-bit Operating System

    Do you have anything that uses TLF in your preloader? It's possible that the TLF framework has made your preloader so heavy that it merely appears to not be doing anything, but the actual case is that all that stuff has to load before it can show you anything.
    You may find this helpful http://jeffkamerer.com/blog/2010/08/12/using-a-custom-preloader-loop-with-tlf-text/
    However, I don't really understand why you feel you have to use TLF to bring in the text from Photoshop. I think you must mean PhotoShop PSD's, because PhotoShop PNG's will not contain editable text (though Fireworks ones can). I get Photoshop comps all the time and bring the text in as Classic Text. While it's not an exact match 100% of the time, it's as close a match as you're going to get based on the limitations of Classic text. I think there's no reason for your designers to be redoing the designs--you just need to play around with the import settings and figure out what gets you close and then what tweaks you need to do to get closer.
    And, to answer your question, nearly everyone creates graphics for Flash files in Photoshop, despite Fireworks being the better tool. For whatever reason, designers often aren't very adventurous when it comes to learning new tools, and nearly all art schools teach PhotoShop.
    I also don't have any trouble loading CS5.5 AS3 swfs (no TLF--I just don't need the hassle) with Document Classes using an ordinary Loader. So I think there's something not right about what you're doing if you've come to the conclusion that you can't load a swf with a Document Class. Try scaling back to the bare minimum, then working up.
    Finally, I just don't "get" why people do two things that you're doing (or, I do, but I think it's unnecessary and a colossal failure on Adobe's part)
    Instantiating everything through code. Not only are you wasting an inordinate amount of time/code in specifying layout, you also completely lose the natural capability of Flash to compile assets throughout the whole of the swf. This means you have to have a preloader, because literally everything you ever use is embedded before the first visual frame. Contrast to using the timeline, where all you need to load the visuals for the first frame is the Document Class (which you can keep light by coding to Interfaces) and the visuals for the first frame. Anything else you need to load, you can defer to the frame that you've selected for embedding your AS Classes on.
    Using a preloader at all.
    My preloading strategy is very simple. I put a spinner graphic in the first frame, with the word "Loading." The playhead will stop at the frame that I've specified to use for exporting my ActionScript Classes (10--this provides enough space for the label "Loading" to be readable). When the embedded Classes and whatever is needed to display frame 11 is loaded, the playhead will continue to frame 11 by itself, with no code. On Frame 11, I have a MC that is a named instance, and I have a getter/setter pair to catch it. When the setter triggers, I know I'm ready to start the logic.
    However, you could do all sorts of things, like just putting a MC there that "is" the entirety of your other logic (has what is now the Document Class of the swf you're preloading as its BaseClass).
    Anyway, maybe something in my ramble will help you.

  • Unable to get the value from the textfield in valueChangeEvent

    Hi,
    I have created one custom textField by extending the CoreInputText. Now i have attched default ValueChangeListener to it. I am using this textField in my application.
    Now i type some thing and do a focus lost, the value change listener get called. i want to validate the value entered. In that listener method if i take the getSource() from ValueChnageEvent object and do a getValue() I am getting the entered value.
    My problem is that if i do a getValue() of the textField i am not gettting the value entered.
    How can i get the entered value from the textfield.? Is there any method to notify to do this?
    Thanks in advance.

    Hi,
    I tried to the value from coreInputText also. If i check the getValue method of the component, i am getting the last updated value. I have debug the FlowPhaseListsner also. And i found that this listener is calling before the updateModel phase. Due to that i am not getting the value from the Field.

  • How to print text from Textfield onto JList?

    Hi!I've typed a sentence on the textfield,and wat can i do to print out this sentence onto the JList i've created,after clicking on my JButton"Post".And on the JList,there must be numbering for each sentence.And New sentences will directly be added after the previous sentence.Hope to get a quick reply from any helpful people.Thanks.

    This should do it. (Typed straight in so untested).
    // create components and event listener
    JTextField textField = new JTextField();
    final DefaultListModel listModel = new DefaultListModel();
    JList list = new JList(listModel);
    JButton button = new JButton("Add");
    button.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent ev)
            String text = textField.getText();
            listModel.add(text);
    // now display them

  • Transaction Posting Confirmation Message and Action Listener behaviour

    Hi, I have a scenario that a user is Posting a Transaction and when he press the “Post” Button a, confirmation dialog box should popup asking “Do you really want to Post the record ?”. If the user press “Yes” the record is further process and If the user press “No” then the transaction should not proceed.
    I have implemented the main screen(PostTransaction.java) and the popup confirmation window(ConfirmationWindow.java)
    Question 1 ) Why the code is not stoping in the Post Button Action listener as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ?
    Question 2) Do I have to write the code for posting of a Transaction(postTransaction() method) in the “ConfirmationWindow”? or it should be in “PostTransaction”.
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;
    public class PostTransaction extends Application{
           public void start(final Stage stage) throws Exception {
                  Group root = new Group();
                  Scene scene = new Scene(root, 300,300);
                  stage.setScene(scene);
                  stage.setTitle("Transaction Post Screen");
                  GridPane gp = new GridPane();
                  Label lblName = new Label("Name");
                  Label lblAmount = new Label("Amount");
                  TextField txtName = new TextField();
                  TextField txtAmount = new TextField();
                  Button btnPost = new Button("Post Record");
                  gp.add(lblName, 1, 1);
                  gp.add(lblAmount, 1, 2);
                  gp.add(txtName, 2, 1);
                  gp.add(txtAmount, 2, 2);
                  gp.add(btnPost, 2, 3);
                  btnPost.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent arg0) {
                             //The code does not stop here as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ??
                             boolean popupResult = ConfirmationWindow.confirmTranactionPosting(stage, "Please Confirm");
                             if(popupResult==true){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Proceeding with Tranaction Posting");
                                  //postTransaction();
                             if(popupResult==false){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Do not Proceed with Tranaction Posting");
                 root.getChildren().add(gp);
                stage.show();
                public static void main(String[] args) {
                  launch(args);
              private void postTransaction(){
                   //write the code for posting here
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    public class ConfirmationWindow extends Stage {
         Stage owner;
         Stage stage;
         BorderPane root;
         static boolean postStatus = false;
      public ConfirmationWindow( Stage owner, String title){
        root = new BorderPane();
        stage = this;
        this.owner = owner;
        initModality( Modality.APPLICATION_MODAL );
        initOwner( owner );
        initStyle( StageStyle.UTILITY );
        setTitle( title );
        setContents();
      public void setContents(){
        Scene scene = new Scene(root,250,150);
        setScene(scene);
        Group groupInDialog = new Group();
        groupInDialog.getChildren().add( new Label("Do you really want to Post this record ?") );
        root.setCenter( groupInDialog );
        Button yes = new Button( "Yes" );
        yes.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =true;
                   stage.close(); // Close the pop up. Transfer control to PostTransaction.java and execute the PostTransaction() method.
        Button no  = new Button( "No" );
        no.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =false;
                   stage.close(); // Close the pop up only
        HBox buttonPane = new HBox();
        buttonPane.setSpacing(10);
        buttonPane.getChildren().addAll(yes,no);
        root.setBottom(buttonPane);
        stage.show();
      public static boolean confirmTranactionPosting(Stage owner, String title) {
           new ConfirmationWindow(owner, title);
           return postStatus;
    }

    The MII Message listener is a queue. But when I understand you correctly, you do not want to process the messages immediately after arriving in the Listener.
    Maybe the categorization of messages is an option for you (see [Sap Help: Processing Rule Editor - Category|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm]. You can enter a category for the control recipe messages. The messages will then be placed in the Listener queue. You can use the [Message Services|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] actions to read the categorized messages and process them as you need.
    In addition to Manoj, you may also use the [Queueing actions|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] of MII, where you can queue xml contents.
    Hope this helps.
    Michael

  • Need some help in textfield

    Hello
    I want to create a textfield that only allows user to key in numerics and with fixed character length (means only a fixed length of characters can be entered).
    I have viewed this post:
    http://forum.java.sun.com/thread.jspa?threadID=536977&messageID=2597211
    and one of the reply said that the numeric part can be done with key listener, but I just don`t know how to do this, even after viewing the API.
    Hope that anyone could help me on this.
    Regards.

    Well the last question you posted dealt with JFrames and JPanels which are Swing components.
    This question deals with a "textfield" which is an AWT component. Most people don't work with both AWT and Swing so I don't know if you just made a typing mistake and meant to say JTextField. Because if you did mean to say JTextField, then the question should have been posted in the Swing forum, so we know for sure that this is a Swing related question.

  • How to keep filename in textfield when filter is changed in a filechooser

    Hi, guys,
    I met a problem to keep filename in textfield when filter is changed in a filechooser
    for example, a JFileChooser has two filters
    *.jpg
    *.png
    Before I open JFileChooser, I used setSelectedFile(File) to set "aaa.jpg" as default name in textfield.
    when I change the filter to "*.png, ", I want to change the text in textfield to "aaa.png", Actually, I used setSelectedFile(File), If there is an existed file named "aaa.png", this file will be selected on fileView, but the name will not be shown on the textfield. Anybody has ideas?
    Thanks in advanced.

    I really thank you for your answer, but it seems you misunderstand what I said because of my poor english..
    what I said is:
    after you open the filechooser, the filechooser has a combobox to choose file filter and a field to show filename.
    what I want is:
    when you open the filechooser, initial name in field is "test. jpg"
    change filter, "test.jpg" will be change to "test.gif" in the field.
    I don't want to close the filechooser.
    That's why I used a listener to listen JFileChooser.FILE_FILTER_CHANGED_PROPERTY event.
    and I modified your codes
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.io.File;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.filechooser.FileFilter;
    class Testing extends JFrame {
         String defaultFile = "";
         JFileChooser fc = new JFileChooser(".");
         ExtensionFileFilter eff;
         public Testing() {
              setLocation(200, 300);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              JButton btnShow = new JButton("Show Chooser");
              JPanel p = new JPanel(new GridLayout(1, 2));
              p.add(btnShow);
              getContentPane().add(p, BorderLayout.SOUTH);
              pack();
              fc.addPropertyChangeListener(new Listener(fc));
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fc.setAcceptAllFileFilterUsed(false);
              fc.setFileFilter(new ExtensionFileFilter(".gif"));
              fc.addChoosableFileFilter(new ExtensionFileFilter(".jpg"));
              defaultFile = defaultFile.equals("") ? "Test.jpg" : "Test.gif";
              fc.setSelectedFile(new java.io.File(defaultFile));
              btnShow.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ae) {
                        fc.showOpenDialog(Testing.this);
         public static void main(String[] args) {
              new Testing().setVisible(true);
    class ExtensionFileFilter extends FileFilter {
         String fileTypes = "";
         java.util.List extensions = new java.util.ArrayList();
         public ExtensionFileFilter() {
         public ExtensionFileFilter(String ft) {
              fileTypes = ft;
         public String getDescription() {
              return fileTypes;
         public boolean accept(File f) {
              if(f.isDirectory()) return true;
              if (f.getName().endsWith(fileTypes)) {
                   return true;
              return false;
    class Listener implements PropertyChangeListener {
        JFileChooser fChooser = null;
        Listener(JFileChooser fChooser) {
            this.fChooser = fChooser;
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
                 FileFilter fileFilter = (FileFilter) evt.getNewValue();
                if (fileFilter != null) {
                    String fileName = null;
                    if (fileFilter.getDescription().equals(".jpg")) {
                        fileName = "Test.jpg";
                    } else if (fileFilter.getDescription().equals(".gif")){
                         fileName = "Test.gif";
                    String newFileName = "C:\\" + fileName;
                    fChooser.setSelectedFile(new File(newFileName));
    }Thanks again.
    Message was edited by:
    JadeSword

  • How to capture the data entered in a textfield in a JTable

    How to capture the data entered in a textfield present in a cell of a textfield or how to add listener to this textfield

    A sample of my code is:
              model = new GridDisplayTableModel(gridDisp,columnName,getRows(),getCols());
              final ComboRenderer cRenderer = new ComboRenderer();
              final TextFieldRenderer tRenderer = new TextFieldRenderer();
              combo.addItem("one");
              combo.addItem("two");
              combo.addItem("three");
              final JTextField textfield = new JTextField();
              final DefaultCellEditor cmbEditor = new DefaultCellEditor(combo);
         //     final JEnterDataCellEditor textEditor = new JEnterDataCellEditor(12);
              final DefaultCellEditor textEditor = new DefaultCellEditor(textfield);
              rm = new RowEditorModel();
              table = new JTable(model){
         public TableCellRenderer getCellRenderer(int row, int column) {
              int posx = 0;
                   int posy = 0;
                   TableCellRenderer renderer = null;
         for(int l=0;l<getDataVec().size();l++)
                   beanObj =(Helperbean)dataVec.elementAt(l);
                   posx = beanObj.getPosx();
                   posy = beanObj.getPosy();
                   if(row==posx && column==posy)
                             if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("textfield"))
                                  rm.addEditorForRow(row,textEditor);
                                  renderer = tRenderer;
                             else if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("combo"))
                                  rm.addEditorForRow(row,cmbEditor);
                                  renderer = cRenderer;
                             break;
                        renderer = super.getCellRenderer(row, column);
              //     System.out.println("getEditor"+rm.getEditor(1));
         return renderer;
    public TableCellEditor getCellEditor(int row, int col) {   
         int posx = 0;
         int posy = 0;
         TableCellEditor tmpEditor = null;
    for(int l=0;l<getDataVec().size();l++)
         beanObj =(Helperbean)dataVec.elementAt(l);
         posx = beanObj.getPosx();
         posy = beanObj.getPosy();
         if(row==posx && col==posy)
                   if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("textfield"))
                        System.out.println("celleditorval "+textEditor.getCellEditorValue());
                        tmpEditor = textEditor;
                   else if(beanObj.getModeofDisplay() != null && beanObj.getModeofDisplay().equalsIgnoreCase("combo"))
                        tmpEditor = cmbEditor;
                   break;
              tmpEditor = super.getCellEditor(row, col);
    return tmpEditor;
    public boolean isCellEditable(int row,int col){
         boolean isEditable = false;
         int posx = 0;
         int posy = 0;
    for(int l=0;l<getDataVec().size();l++)
         beanObj =(Helperbean)dataVec.elementAt(l);
         posx = beanObj.getPosx();
         posy = beanObj.getPosy();
         if(row==posx && col==posy)
              if(beanObj.getModeofDisplay() != null )     
                        isEditable = true;     
                   else
                        isEditable = false;     
                   break;
         isEditable = false;
         return isEditable;
    public void changeSelection(final int row, final int column, boolean toggle, boolean extend) {
         super.changeSelection(row, column, toggle, extend);
         //my attempt to avoid editCellAt from being called twice in a row
         if (getModel().isCellEditable(row, column) && !(isEditing() && getEditingRow() == row && getEditingColumn() == column))
              if (editCellAt(row, column)) {
                   getEditorComponent().requestFocus();
         // Select the text when the cell starts editing
    public boolean editCellAt(int row, int column) {       
         boolean result = super.editCellAt(row, column);
         final Component editor = getEditorComponent();
         if (editor != null && editor instanceof JTextField) {           
              SwingUtilities.invokeLater(new Runnable() {               
                   public void run() {                   
                        ((JTextField)editor).selectAll();
              return result;
         public boolean hasFocus()
              Component editorComponent = getEditorComponent();
              // Try to install the editor
              int anchorRow = getSelectionModel().getAnchorSelectionIndex();
              int anchorColumn = getColumnModel().getSelectionModel().
              getAnchorSelectionIndex();
              if (anchorRow != -1 && anchorColumn != -1 && !isEditing())
              if ((this.getSelectedRow() == anchorRow) && (this.getSelectedColumn() == anchorColumn))
              if (!editCellAt(anchorRow, anchorColumn)) {}
              return super.hasFocus();
         public void valueChanged(ListSelectionEvent e)
              super.valueChanged(e);
              if ((this.getSelectedRow() == 2) && (this.getSelectedColumn() == 3))
                   DefaultFocusManager focusManager = new DefaultFocusManager();
                   focusManager.focusNextComponent(this);
                   model.fireTableStructureChanged();
         

Maybe you are looking for