Cell event listener

Hi,
Assume I have jtable which have three column: numberone, numbertwo, and result.....
I put value 1 into numberone column ( row one ), and put value 2 into numbertwo column (row one).... and when I press Enter or change the cell to down or left or right, suddenly result column is put value 3. This is simple addition jtable. How do I make such event listener. When I change the cell( after putting value in numberone column and numbertwo column ), the result column compute the value in numberone column and numbertwo column.

what's wrong????My testing stinks.import java.awt.*;
import javax.swing.event.*;
import javax.swing.*;
public class Test3 extends JFrame {
  JTable jt = new JTable(10,3);
  public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    jt.getModel().addTableModelListener(new TableModelListener() {
      public void tableChanged(TableModelEvent tme) {
        int col=tme.getColumn(), row=tme.getFirstRow();
        if (col!=2) {
          try {
            int val0 = Integer.parseInt(jt.getValueAt(row, 0).toString()),
                val1 = Integer.parseInt(jt.getValueAt(row, 1).toString());
            jt.setValueAt(new Integer(val0 + val1), row, 2);
          } catch (Exception e) {
            jt.setValueAt("Error", row, 2);
    setSize(300,300);
    setVisible(true);
  public static void main(String[] args) { new Test3(); }
}

Similar Messages

  • JTable Cell Change Listener

    I have a JTable which contains all the services charges and It should automatically calculate the Total of all the service Charges and so my client wants that on JTable Cell Change the total field should be updated
    So Can any body give me the event listener for that
    Thanks in advance
    CSJakharia

    Thanks for that
    That Works But do u know anything which prevents the continous loop
    I mean I have to change certain fields in the JTable itself in the listner itself and if i do that it ends up in Stack Overflow Exception Which implies never ending loop
    I can stop that with the use of variable But is there any easy way out I mean any method by which i can stop this endless LOOP

  • Adding an event listener to combo box

    I am working on a mortgage calculator and I cannot figure out how to add an event listener to a combo box.
    I want to get the mortgage term and interest rate to calucate the mortgage using the combo cox. Here is my program.
    Modify the mortgage program to allow the user to input the amount of a mortgage
    and then select from a menu of mortgage loans: 7 year at 5.35%, 15 year at 5.50%, and
    30 year at 5.75%. Use an array for the different loans. Display the mortgage payment
    amount. Then, list the loan balance and interest paid for each payment over the term
    of the loan. Allow the user to loop back and enter a new amount and make a new
    selection, with resulting new values. Allow user to exit if running as an application
    (can't do that for an applet though).
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.NumberFormat;
    import java.util.Locale;
    //creates class MortgageCalculator
    public class MortgageCalculator extends JFrame implements ActionListener {
    //creates title for calculator
         JPanel row = new JPanel();
         JLabel mortgageCalculator = new JLabel("MORTGAGE CALCULATOR", JLabel.CENTER);
    //creates labels and text fields for amount entered          
         JPanel firstRow = new JPanel(new GridLayout(3,1,1,1));
         JLabel mortgageLabel = new JLabel("Mortgage Payment $", JLabel.LEFT);
         JTextField mortgageAmount = new JTextField(10);
         JPanel secondRow = new JPanel();
         JLabel termLabel = new JLabel("Mortgage Term/Interest Rate", JLabel.LEFT);
         String[] term = {"7", "15", "30"};
         JComboBox mortgageTerm = new JComboBox(term);
         JPanel thirdRow = new JPanel();
         JLabel interestLabel = new JLabel("Interest Rate (%)", JLabel.LEFT);
         String[] interest = {"5.35", "5.50", "5.75"};
         JComboBox interestRate = new JComboBox(interest);
         JPanel fourthRow = new JPanel(new GridLayout(3, 2, 10, 10));
         JLabel paymentLabel = new JLabel("Monthly Payment $", JLabel.LEFT);
         JTextField monthlyPayment = new JTextField(10);
    //create buttons to calculate payment and clear fields
         JPanel fifthRow = new JPanel(new GridLayout(3, 2, 1, 1));
         JButton calculateButton = new JButton("CALCULATE PAYMENT");
         JButton clearButton = new JButton("CLEAR");
         JButton exitButton = new JButton("EXIT");
    //Display area
         JPanel sixthRow = new JPanel(new GridLayout(2, 2, 10, 10));
         JLabel displayArea = new JLabel(" ", JLabel.LEFT);
         JTextArea textarea = new JTextArea(" ", 8, 50);
    public MortgageCalculator() {
         super("Mortgage Calculator");                     //title of frame
         setSize(550, 350);                                             //size of frame
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container pane = getContentPane();
         GridLayout grid = new GridLayout(7, 3, 10, 10);
         pane.setLayout(grid);
         pane.add(row);
         pane.add(mortgageCalculator);
         pane.add(firstRow);
         pane.add(mortgageLabel);
         pane.add(mortgageAmount);
         pane.add(secondRow);
         pane.add(termLabel);
         pane.add(mortgageTerm);
         pane.add(thirdRow);
         pane.add(interestLabel);
         pane.add(interestRate);
         pane.add(fourthRow);
         pane.add(paymentLabel);
         pane.add(monthlyPayment);
         monthlyPayment.setEnabled(false);
         pane.add(fifthRow);
         pane.add(calculateButton);
         pane.add(clearButton);
         pane.add(exitButton);
         pane.add(sixthRow);
         pane.add(textarea); //adds texaarea to frame
         pane.add(displayArea);
         setContentPane(pane);
         setVisible(true);
         //Adds Listener to buttons
         calculateButton.addActionListener(this);
         clearButton.addActionListener(this);
         exitButton.addActionListener(this);
         mortgageTerm.addActionListener(this);
         interestRate.addActionListener(this);
    public void actionPerformed(ActionEvent event) { 
         Object command = event.getSource();
         JComboBox mortgageTerm = (JComboBox)event.getSource();
         String termYear = (String)mortgageTerm.getSelectedItem();
    if (command == calculateButton) //calculates mortgage payment
         int year = Integer.parseInt(mortgageTerm.getText());
         double rate = new Double(interestRate.getText()).doubleValue();
         double mortgage = new Double(mortgageAmount.getText()).doubleValue();
         double interest = rate /100.0 / 12.0;
         double monthly = mortgage *(interest/(1-Math.pow(interest+1,-12.0 * year)));
                   NumberFormat myCurrencyFormatter;
                   myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US);
                   monthlyPayment.setText(myCurrencyFormatter.format(monthly));
         if(command == clearButton) //clears all text fields
                   mortgageAmount.setText(null);
                   //mortgageTerm.setText(null);
                   //interestRate.setText(null);
                   monthlyPayment.setText(null);
              if(command == exitButton) //sets exit button
                        System.exit(0);
         public static void main(String[] arguments) {
              MortgageCalculator mor = new MortgageCalculator();

    The OP already did this to both JComboBoxes.
    mochatay, here is a new actionPerformed method for you to use.
    I've improved a few things here and there...
    1) You can't just cast the ActionEvent's source into a JComboBox!
    What if it was a JButton that fired the event? Then you would get ClassCastExceptions (I'm sure you did)
    So check for all options, what the source of the ActionEvent actually was...
    2) You can't assume the user will always type in valid data.
    So enclose the Integer and Double parse methods in try-catch brakcets.
    Then you can do something when you know that the user has entered invalid input
    (like tell him/her what a clumsy idiot they are !)
    3) As soon as user presses an item in any JComboBox, just re-calculate.
    I did this here by programmatically clicking the 'Calculate' button.
    Alternatively, you could have a 'calculate' method, which does everything inside the
    if(command==calculateButton) if-block.
    This will be called when:
    a)calculateButton is pressed
    b)when either of the JComboBoxes are pressed.
    public void actionPerformed (ActionEvent event)
            Object command = event.getSource ();
            if (command == calculateButton) //calculates mortgage payment
                int year = 0;
                double rate = 0;
                double mortgage = 0;
                double interest = 0;
                /* If user has input invalid data, tell him so
                and return (Exit from this method back to where we were before */
                try
                    year = Integer.parseInt (mortgageTerm.getSelectedItem ().toString ());
                    rate = new Double (interestRate.getSelectedItem ().toString ()).doubleValue ();
                    mortgage = new Double (mortgageAmount.getText ()).doubleValue ();
                    interest = rate / 100.0 / 12.0;
                catch (NumberFormatException nfe)
                    /* Display a message Dialogue box with a message */
                    JOptionPane.showMessageDialog (this, "Error! Invalid input!");
                    return;
                double monthly = mortgage * (interest / (1 - Math.pow (interest + 1, -12.0 * year)));
                NumberFormat myCurrencyFormatter;
                myCurrencyFormatter = NumberFormat.getCurrencyInstance (Locale.US);
                monthlyPayment.setText (myCurrencyFormatter.format (monthly));
            else if (command == clearButton) //clears all text fields
                /* Better than setting it to null (I think) */
                mortgageAmount.setText ("");
                //mortgageTerm.setText(null);
                //interestRate.setText(null);
                monthlyPayment.setText ("");
            else if (command == exitButton) //sets exit button
                System.exit (0);
            else if (command == mortgageTerm)
                /* Programmatically 'clicks' the button,
                As is user had clicked it */
                calculateButton.doClick ();
            else if (command == interestRate)
                calculateButton.doClick ();
            //JComboBox mortgageTerm = (JComboBox) event.getSource ();
            //String termYear = (String) mortgageTerm.getSelectedItem ();
        }Hope this solves your problems.
    I also hope you'll be able to learn from what I've indicated, so you can use similar things yourself
    in future!
    Regards,
    lutha

  • Can't remove event listener from Image

    I'm clearly missing something and would appreciate some help.  I'm trying to run an event handler when an Image completes loading,  then remove the handler so that it won't  run again should the image be reloaded later.
    The problem that I'm having is that the event handler simply wont' go away, despite calling removeEventListener on the Image object.
    The following example demonstrates the problem (the example doesn't actually do anything useful...it's just the shortest example to demonstrate the problem).  (To run the  app, you'll have to provide any ol' JPEG file named "myImage.jpg" in the "src" directory of your project).
    What I expect to happen is :
         1) on startup, the image loads and loadComplete() runs.
         2)  loadComplete removes the event Listener so that subsequent re-loads won't re-fire the handler.  I only want the handler to  run once.
         3) "loadComplete" shoudl  be displayed in the Debug console.
         4) A button click should display only "Changing  Image" in the Debug console
    What I get instead is that the loadComplete handler isn't  removed, and every  time I click the button, loadComplete runs when the image is re-loaded   (i.e., every button click results in both "Change Image" AND "loadComplete"  being displayed in the Debug console).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Image width="655" height="181" source="myImage.jpg" id="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" x="100" y="100"/>
        <mx:Button x="100" y="341" label="Button" click="click(event)"/>
        <mx:Script>
            <![CDATA[
                private function loadComplete():void
                    trace ("loadComplete");
                    myImage.removeEventListener("complete", loadComplete);
                private function click(evt:Event):void
                    trace ("Changing Image");
                    myImage.load("myImage.jpg");    //  Reload same image; it's just an example
            ]]>
        </mx:Script>
    </mx:Application>

    Hi,
    You can remove only event listeners that you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener  that was defined in the MXML tag, even if it was registered using a call  to the addEventListener()method that was made inside a tag attribute.
    Check this page for reference.
    http://livedocs.adobe.com/flex/3/html/help.html?content=events_05.html
    You can modify the code a bit a get it working
    <mx:Image width="655" height="181" id="myImage" scaleContent="true"
              x="100" y="100"
              creationComplete="myImage_creationCompleteHandler(event)"/>
    private function myImage_creationCompleteHandler(event:FlexEvent):void
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    private function myImage_completeHandler(event:Event):void
         myImage.removeEventListener("complete",myImage_completeHandler);

  • How do I assign a mouseclick event Listener to a simplebutton already nested in a movie clip when it's dropped on stage?

    I'm trying to assign a mouseclick event listener to a simplebutton nested within a movie clip's later frames, starting at frame 2 and up. This card, however, is not added to my game until later, and when the player clicks on it/turns it over.
    There are four files involved in this program:
    #1 The main actionscript file, which corresponds to
    #2 my dreamQuester .fla file.
    #3 my artifactCard file movieClip's corresponding .as file,
    #4 my combo1.as file corresponding to a an instance of a simpleButton named combo1 that is already
    nested --and this instance is already named-- inside/as a child of said artifactCard movieclip.
    What I've done so far isn't working:
    In my main dreamQuester.as file, when a player clicks on an artifactCard, its MOUSE_DOWN event
    listener takes them to this function (clickArtCard), where the trouble is at:
    // player clicked on the artC card--which is a child of posArt1 on stage--to turn card over:
            function clickArtCard(a_event:MouseEvent) {
                var thisArtCard:artifactCard = (a_event.target as artifactCard);
                thisArtCard.gotoAndStop(unclickedArt1);  // go to frame number of artifact
                                    // card where combo1 button is.
                thisArtCard.removeEventListener(MouseEvent.CLICK,clickArtCard);
                thisArtCard.buttonMode = false;
                trace("combo1.combo is:" + combo1.combo);
                trace("posArt1.artC.combo1 is:" + posArt1.artC.combo1);
                posArt1.artC.combo1.addEventListener(MouseEvent.MOUSE_DOWN, comboClickedWHO);
    when the artC card--the static public instance of artifactCard--is clicked, it only gets to the
    trace("posArt1.artC.combo1 is:" + posArt1.artC.combo1); which returns this error message:  
    TypeError: Error #1010: A term is undefined and has no properties.
        at MethodInfo-61()
    So do how would I declare a static public variable of this simpleButton at the start of my main .as
    file to make it defined to get a mouseDown actionListener into my pre-existing-and-named-instance
    combo1 simpleButton?
    perhaps there is a way, while the debug movie program is running, to click on the simpleButton and see exactly
    what it's parent heirarchy is, to see the name of all parents above the simpleButton incase they are
    different then what I think?
    (just in case, I was hoping to squeeze a zip file containing these files to be less than 9MB incase someone was willing to look at my files to see what I've done so far, but 9 megs is just too big! even though all graphics I've imported where turned into vector graphics with trace bitmap. I wish there was a way to check the file size of each symbol in Flash CS4, here...)
    Thank you so much for any help!
    ~Ethan

    Just use a
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
    function keyPressed(event:KeyboardEvent):void {
         //trace(event.keyCode);
         if(event.keyCode == ???){
              // play the sound
    Where I show the "???" you would replace with the keyCode for the key you want pressed for that sound.  To determine the keyCode you can use the trace line that I have commented out.
    Note that when testing in Flash you often need to disable the keyboard shortcuts in the Flash Player in order to be able to use alot of the keys.  You will find this option in the Control menu options in the player.

  • How can I check if a function is or is not called from the event listener? in Flash CS4 (AS3)

    Hi,
    I came across a little problem.
    I put an event listener inside a for loop and the for loop inside a function.
    I want the for loop to end as soon as the event listener inside the for loop calls its function.
    Here is the general code for a better picture.
    Code:
    this.addEventListener(Event.ENTER_FRAME, function#1);
    function function#1(event:Event):void{
              if(something is true){
                        for(var i = 0; i < numOfmy_mcs; i++){
                                  this["my_mc_"+String(i)].addEventListener(MouseEvent.CLICK, function#2);
    function function#2(e:Event):void{
    //do something cool here
    Thank you for any help!

    kglad wrote:
    that for-loop (if it executes), defines listeners for interactive objects.  that will complete long before any object is clicked.
    Well yes but it does it again and again (frames per second times seconds = number of times it goes through the code if i'm not mistaken), because it is inside a function, and through testing i found out that it works like this:
    Example:
    there are 5 my_mc's in my project: (my_mc_0, my_mc_1, my_mc_2, my_mc_3, my_mc_4)
    if i click my_mc_0 function#2 is called and executed. BUT only after the loop finishes (i know this from tons of testing)...which is unnecessary since you cannot click two places at once. This might not be a problem in this example because i am only using 5 my_mc's buy if i use 500000000 my_mc's it would make a lot of difference.
    is there a way to stop the loop if the function is called?
    ...maybe there is a better way to write it, the only alternative i know that works is if i manually write every single listener and this also is logical in this example but as i said next to impossible if the numbers get bigger.
    -Note
    I didn't specify this earlier but function#2 makes the if statement false so it wont jump back into it.
    Thank you for the help I really appreciate it!
    3rd edit...don't know what's wrong with me

  • Help with event listener

    I'm having some trouble trying to figure out how this event listener will work.
    The main application is building an arrayCollection of a calendarDay custom components which is displayed by a DataGroup.
    Within each calendarDay custom component i may create an arrayList of a DriverDetailComponent custom components displayed within the calendarDay by a DataGroup.
    If a user double clicks on the DriverDetailComponent that is two layers in I would like to change states of the main application.  I'm having trouble figuring out what item in the main application to set the listener on.  Please help.
    I can't figure out how to post the below as scrollable code snips so this is very long.
    Main application code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*"
                   preinitialize="readDataFile()"
                   creationComplete="buildRowTitles()"
                   width="1024" height="512"  backgroundColor="#A4BDD8">
        <s:states>
            <s:State name="State1"/>
            <s:State name="driverDetailState"/>
        </s:states>
        <!--
        <fx:Style source="EventCalendar.css"/>
        creationComplete="readDataFile()"    creationComplete="driversList.send()"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->       
            <mx:DateFormatter id="myDateFormatter"
                              formatString="EEE, MMM D, YYYY"/>
            <!--<s:HTTPService id="driversList"
                           url="files/drivers.xml"
                           result="driversList_resultHandler(event)"
                           fault="driversList_faultHandler(event)"/>
            <s:HTTPService id="postDriversList"
                           url="files/drivers.xml"
                           method="POST"
                           result="postDriversList_resultHandler(event)"
                />-->
            <!--<s:Move id="expandTab"
                    target="{labelTab}"
                    xBy="250"/>-->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.TruckDriver;
                import components.calendarDay;
                import events.CancelChangeDriversEvent;
                import events.ChangeDriversEvent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.containers.Form;
                import mx.controls.Alert;
                import mx.controls.CalendarLayout;
                import mx.core.FlexGlobals;
                import mx.core.IVisualElement;
                import mx.core.WindowedApplication;
                import mx.printing.FlexPrintJob;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.xml.SimpleXMLEncoder;
                import spark.components.Application;
                import utilities.FormatUtil;
                import utilities.ObjectToXML;
                /* public var prefsFile:File; */ // The preferences prefsFile
                [Bindable] public var driversXML:XML; // The XML data
                public var stream:FileStream; // The FileStream object used to read and write prefsFile data.
                public var fileName:String="driversArrayCollection";
                public var directory:String = "AceTrackerData";
                public var dataFile:File = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
                [Bindable]
                public var drivers:ArrayCollection=new ArrayCollection();
                private var fileStream:FileStream;
                [Bindable]
                public var calendarDayArray:ArrayCollection = new ArrayCollection;
                public var i:int;
                [Bindable]
                public var weekOneTitle:String;
                [Bindable]
                public var weekTwoTitle:String;
                [Bindable]
                public var weekThreeTitle:String;
                [Bindable]
                public var weekFourTitle:String;
                public var day:Object;
                protected function readDataFile():void
                    if(dataFile.exists)
                        fileStream = new FileStream();
                        fileStream.open(dataFile, FileMode.READ);
                        drivers = fileStream.readObject() as ArrayCollection;
                        fileStream.close();
                    else
                        drivers = new ArrayCollection();
                        var driver:TruckDriver = new TruckDriver("New", "Driver", 000);
                        drivers.addItem(driver);
                        saveData(drivers);
                    buildCalendarArray();
                protected function buildCalendarArray():void
                    calendarDayArray.removeAll();
                    for (i=0; i<28; i++)
                        var cd:calendarDay = new calendarDay;
                        cd.dateOffset= i-7
                        cd.drivers=drivers;
                         cd.addEventListener("editDriverEvent",editDriverEvent_Handler);
                        calendarDayArray.addItem(cd);
              private function saveData(obj:Object):void//this is called on the postDriversList result handler to create and write XML data to the file
                    var fs:FileStream = new FileStream();
                    fs.open(dataFile, FileMode.WRITE);
                    /* fs.writeUTFBytes(myXML); */
                    fs.writeObject(drivers);
                    fs.close();
                protected function driverschedule1_changeDriversHandler(event:ChangeDriversEvent):void
                    saveData(drivers); 
                    readDataFile();//i read the drivers file again, this refreshes my data, and removes any temporary data that may have been stored in the drivers array
                    buildCalendarArray();
                    currentState = 'State1';//this hides the driversdetail window after we've clicked save
                    /* postDriversList.send(event.driverInfo); */  //this needs to be different
                    /* Alert.show("TEST"); */
                protected function driverschedule1_cancelChangeDriversHandler(event:CancelChangeDriversEvent):void
                    /* Alert.show("Changes have been canceled."); */
                    readDataFile();//this re-reads the saved data file so that the changes that were made in the pop up window
                    // are no longer reflected if you reopen the window
                    buildCalendarArray();
                    currentState = 'State1';  //this hides the driversdetail window after we've clicked cancel
                protected function buildRowTitles():void
                    var calendarDay0:Object;
                    var calendarDay6:Object;
                    calendarDay0=calendarDayArray.getItemAt(0);
                    calendarDay6=calendarDayArray.getItemAt(6);
                    weekOneTitle = calendarDay0.getDayString() + " - " + calendarDay6.getDayString();
                    weekTwoTitle=calendarDayArray.getItemAt(7).getDayString()+ " - " + calendarDayArray.getItemAt(13).getDayString();
                    weekThreeTitle=calendarDayArray.getItemAt(14).getDayString()+ " - " + calendarDayArray.getItemAt(20).getDayString();
                    weekFourTitle=calendarDayArray.getItemAt(21).getDayString()+ " - " + calendarDayArray.getItemAt(27).getDayString();
            ]]>
        </fx:Script>
        <s:Group height="100%" width="100%">
            <s:layout>
                <s:BasicLayout/>  <!--This is the outermost layout for the main application MXML-->
            </s:layout>
        <s:Scroller width="95%" height="100%"  >
        <s:Group height="100%" width="100%"  ><!--this groups the vertically laid out row titles hoizontally with the large group of calendar days and day titles-->
            <s:layout>
                <s:HorizontalLayout/>
            </s:layout>
        <s:Group height="95%" width="50" ><!--this is the group of row titles layed out vertically-->
            <s:layout>
                <s:VerticalLayout paddingLeft="40" paddingTop="35"/>
            </s:layout>
            <s:Label text="{weekOneTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekTwoTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center" />
            <s:Label text="{weekThreeTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekFourTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
        </s:Group>
        <s:Group height="100%" width="100%" >
            <!--this vertically groups together the horizontal day names group and the tile layout datagroup of calendar days-->
            <s:layout>
                <s:VerticalLayout paddingLeft="5"/>
            </s:layout>
        <s:Group width="100%" >
            <s:layout><!--this group horizontal layout is for the Day names at the top-->
                <s:HorizontalLayout paddingTop="10"/>
            </s:layout>
            <s:Label id="dayNames" text="Sunday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Monday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Tuesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Wednesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Thursday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Friday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Saturday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
        </s:Group>
            <!--<s:SkinnableContainer width="16%">-->
                <s:DataGroup id="calendarDataGroup"
                             dataProvider="{calendarDayArray}"
                             itemRenderer="{null}"  resizeMode="scale"
                              height="100%" width="100%"
                              >  <!--  I had to use a null renderer because otherwise each instance is added in a group container renderers.DriverScheduleRenderer-->
                    <s:layout >
                        <s:TileLayout requestedColumnCount="7" />
                    </s:layout>
                </s:DataGroup>
            <!--</s:SkinnableContainer>-->
        <!--<mx:FormItem label="Today's Date:">
            <s:TextInput id="dateToday"
                         text="{myDateFormatter.format(testDate)}"/>
        </mx:FormItem>-->
        <!--<components:DriverSchedule drivers="{drivers}"
                                   changeDriversEvent="driverschedule1_changeDriversHandler(event)"/>-->
            <s:HGroup>  <!--this groups together my drivers button and my print button at the bottom of the calendar-->
            <s:Button id="showDriverDetailButton"
                      label="Driver List"
                      click="currentState = 'driverDetailState'">
                <!--</s:Button>
                <s:Button id="printButton"
                    label="Print"
                    >  click="printButton_clickHandler(event)"-->
                </s:Button>
            </s:HGroup>    <!--this is the end of the small hgroup which pairs my drivers button with the print button-->                  
        </s:Group><!--this ends the vertical grouping of the day names and the tile layout calendar-->   
    </s:Group>        <!--this ends the horizontal grouping of the calendar (names and days) with the week labels at the left-->
        </s:Scroller>
            <s:SkinnableContainer includeIn="driverDetailState"
                                  width="95%" height="95%"  horizontalCenter="0" verticalCenter="0"
                                  backgroundColor="#989898" backgroundAlpha="0.51">
                <s:BorderContainer horizontalCenter="0" verticalCenter="0">
                <components:DriverSchedule id="driverSchedule"
                                            drivers="{drivers}"
                                           changeDriversEvent="driverschedule1_changeDriversHandler(event)"
                                           cancelChangeDriversEvent="driverschedule1_cancelChangeDriversHandler(event)"
                                           />
                </s:BorderContainer>
            </s:SkinnableContainer>
        </s:Group>  <!--end of basic layout group-->
    </s:WindowedApplication>
    </code>
    calendarDay.mxml code:
    <code>
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx"
             creationComplete="initDay()"
              width="100%">  <!--width="16%" height="25%"  width="160" height="112"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:DateFormatter id="myDateFormatter"
                              formatString="MMM D"/>
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.DriverDetailComponent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.controls.CalendarLayout;
                import mx.controls.DateField;
                [Bindable]
                public var todayCollection:ArrayCollection = new ArrayCollection;
                [Bindable]
                public var todayList:ArrayList=new ArrayList; //arraylist created as data provider for dataGroup, this is where all drivers with an arrival date of today are added
                [Bindable]
                public var currDate:Date =new Date; //this will be used to contain the current real world date
                [Bindable]
                public var calDate:Date = new Date; //this is used below to determine the date of the calender day that is being created
                [Bindable] 
                public var todaysDate:CalendarDay;
                [Bindable]
                public var currDay:int;
                [Bindable]
                public var dateOffset:int;
                public var drivers:ArrayCollection= new ArrayCollection();
                   public var driver:Object;  
                public var rowLabel:String;
                public function initDay():void
                    todaysDate  = new CalendarDay(currDate, currDate.day, dateOffset)//currDate represents the day the operating system says today is
                        currDay=todaysDate.returnDate().getDate();//currDay is an int representing the day of the month
                        calDate=todaysDate.returnDate();//calDate represents the actual date on the calendar (MM-DD-YYY) that is currently being evaluated
                        /* if (currDay ==currDate.getDate()) //i want to highlight the day if it is in fact today
                            cont.styleName="Today";
                            if (calDate.getDate() == currDate.getDate())
                            calDayBorder.setStyle("backgroundColor", "#FFFF00");
                        else
                            calDayBorder.setStyle("backgroundColor", "#EEEEEE");
                         addDrivers(); 
                    return;
                  public function addDrivers():void
                       var count:int = 0;
                      /*var driverDetail:DriverDetailComponent;
                      var driver =  */
                    for each (driver in drivers)
                    {//i check the date value based on data entry of mm-dd-yy format against the calculated date for the day
                        //the calender is building and if it is equal the drivers information is added to this day of the calendar
                        if (DateField.stringToDate(driver.arrivalDate,"MM/DD/YYYY").getDate() == calDate.getDate())
                                var driverDetail:DriverDetailComponent = new DriverDetailComponent; //i create a new visual component that adds the id and destination to the calendar day
                                driverDetail.driverid = drivers[count].id; //i feed the id property which is the truck# - firstName
                                driverDetail.driverToLoc=drivers[count].toLoc; //i feed the toLoc which is the current destination of the driver
                                driverDetail.driverArrayLocation=count;   //here i feed the location of this driver in the "drivers" array so i know where it's at for the click listener
                                todayList.addItem(driverDetail);
                            //this concatenates the drivers truck number first name and destination to display in the calendar day
                                /* todayList.addItem(driver.truckNumber + " - " + driver.firstName + " - " + driver.toLoc); */
                    count ++;
                public function getDayString():String
                    rowLabel =myDateFormatter.format(calDate);
                    return rowLabel;
            ]]>
        </fx:Script>
        <s:BorderContainer id="calDayBorder" width="160" styleName="Today" cornerRadius="2" dropShadowVisible="true" height="100%">
            <s:layout>
                <s:BasicLayout/>   
            </s:layout>
            <!--I need to make a custom item renderer for my calendar days that limits the height and width of the day, and also puts the items
            closer together so i can fit maybe 5 drivers on a single day-->
            <s:DataGroup dataProvider="{todayList}"
                         itemRenderer="spark.skins.spark.DefaultComplexItemRenderer"
                         bottom="-2"
                         width="115" left="2">  <!--width="94%"  width="100"  width="16%"-->
                <s:layout >
                    <s:VerticalLayout gap="-4"/> <!--The reduced gap pushes the drivers together if there are serveral on one day. This helps cleanly show several drivers on one day-->
                </s:layout>
            </s:DataGroup >
            <s:Label  text="{currDay}" right="3" top="2" fontSize="14" fontWeight="bold"/>
        </s:BorderContainer>
    </s:Group>
    </code>
    DriverDetailComponent code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import events.EditDriverEvent;
                import mx.controls.Alert;
                [Bindable]
                public var driverid:String;
                [Bindable]
                public var driverArrayLocation:int;
                [Bindable]
                public var driverToLoc:String;
                protected function label1_doubleClickHandler(event:MouseEvent):void
                    Alert.show("You have selected " +driverid +" at location "  + driverArrayLocation.toString() +" in the drivers ArrayCollection.");
                    var eventObject:EditDriverEvent = new EditDriverEvent("editDriverEvent",driverArrayLocation);
                    dispatchEvent(eventObject);
            ]]>
        </fx:Script>
        <s:Label id="driverDetailLabel" text="{driverid} - {driverToLoc}"  doubleClick="label1_doubleClickHandler(event)" doubleClickEnabled="true"/>
    </s:Group>
    </code>

    lkb3 wrote:
    I'm trying to add a listener to [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|my dialog box], so that when it pops up, the cursor is in the text box, but then if the user clicks a button other than the default, the cursor reverts back into the text box.
    The code I have is this:
      // BUILD DIALOG BOX
    JLabel option_label = new JLabel("Select a search option:");
    // Create the button objects
    JRadioButton b1 = new JRadioButton("Search PARTS by name");
    JRadioButton b2 = new JRadioButton("Search ASSEMBLIES by name");
    JRadioButton b3 = new JRadioButton("Search DRAWINGS by name");
    JRadioButton b4 = new JRadioButton("Search all by DESCRIPTION");
    b1.setSelected(true);
    // Tie them together in a group
    ButtonGroup group = new ButtonGroup();
    group.add(b1);
    group.add(b2);
    group.add(b3);
    group.add(b4);
    // Add them to a panel stacking vertically
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
    panel.add(b1);
    panel.add(b2);
    panel.add(b3);
    panel.add(b4);
    JLabel name_label = new JLabel("Enter a search term (add *'s as required)");
    JTextField name = new JTextField(30);
    name.addComponentListener(new ComponentListener() {
    public void componentHidden(ComponentEvent ce) { }
    public void componentMoved(ComponentEvent ce) { }
    public void componentResized(ComponentEvent ce) {
    ce.getComponent().requestFocus();
    public void componentShown(ComponentEvent ce) { }
    Object[] array = { option_label, panel, name_label, name };
    // GET INPUT FROM USER
    int res = JOptionPane.showConfirmDialog(null, array, "Select", JOptionPane.OK_CANCEL_OPTION);
    String searchTerm = name.getText();This sucessfully has the focus in the text box when opened; is there a way to get the focus to go back into the text box after the user clicks a radio button?
    Thanks!
    [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|dialog Joption]
    you will need to add ItemListener to the JRadioButtons

  • Remove event listener from loaded external swf

    I have a main movie timeline that loads an external swf. When I unload the swf from the main timeline I get an error from this:  my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, vidEnd);
    is there any way to remove the event listener from the loaded swf from the main timeline?
    THANKS!

    if you're publishing for fp 10+, use unloadAndStop() applied to your swf's loader.  that has a fair chance of solving the problem.
    if that fails, you should explicitly stop my_FLVPlybk.

  • Keyboard Event Listener doesn't work in Browser

    Is there a reason why a keyboard event listener would not work if the flash is embedded in an HTML? The rest of my game is running fine in the background, but I can't launch the movieClip "nextCar." My code is below, if that makes any difference...
    function goNow (event:KeyboardEvent): void {
        thisOtherKey = event.keyCode;
        if (thisOtherKey == 32) {
            nextCar.gotoAndPlay(2);
            parkingQue.play();
            tries++;
    stage.addEventListener(KeyboardEvent.KEY_DOWN, goNow);

    This may be a silly question, but have you tryed clicking on your swf after it opens up in the browser, and then trying the keyboard controls?
    I don't know of any issues that cause event listeners to workwhen debugging, but not in a browser.  So, I'm thinking maybe your just not focused on the swf.

  • How to send the Event Listener arguments in AS3?

    In MXML
    <mx:Button click="clickHandler();"
    mouseDown="downHandler(event);" mouseOver="overHandler(btn);"
    mouseMove="moveHandler('RAJAN');"/>
    but AS3
    var btn:Button = new Button();
    btn.addEventListener(MouseEvent.CLICK, clickHandler, flase,
    0, true);
    only this kind of AS3 event only added, any other possibility
    to pass the arguments to handler function.
    please help.

    From that link:
    If you define an event listener inline (inside the MXML tag),
    you can add any number of parameters as long as the listener
    function's signature agrees with that number of parameters.
    If you add a listener with the addEventListener() method (in
    ActionScript), you cannot pass any additional parameters to the
    listener function, and that listener function can declare only a
    single argument, the Event object (or one of its subclasses).
    To pass additional parameters to listener functions defined
    in AS, you must define the parameters in the listener function and
    then call some other method passing it the additional parameters in
    the call from the listener.
    You can also define your own custom events, and then you are
    free to define what args your event listeners take, and access the
    data from the event object.

  • Is there any event listener for changing the selection of layer?

    Hi all,
    I am looking into an event listener which fires on changing the selection of layer. I found 'Select' event listener which fires on selecting the different object.
    Actually the problem with Select event listener is that when we select an object and move it and deselect it by clicking on the document, event fires on the selection of that object. But if we again select the same object and move it, no event is fired at that time.
    Is there any workaround of this? So that the event is fired every time when we select the same object.
    Please help me on this..
    Regards,
    VG.

    Thanks for the reply..
    Actually I want the same behaviour as in illustrator i.e
    - Select a layer. (Notifier calls the listener)
    - Move it.
    - Click on the document.
    - Again select the same layer. (Notifier calls the listener again)
    - Move it.
    But in photoshop,
    - Select a layer. (Notifier calls the listener)
    - Move it.
    - Click on the document.
    - Again select the same layer. (Notifier doesnot calls the listener again as the layer is already selected in panel as you explained.)
    - Move it.
    Is there any way to get the same behaviour of illustrator in photoshop?

  • How does custom event listener work.

    Hi,
    With reference to Custom Event Listener, I wanted to know the behaviour of Custom Listener whether they are sync or async.
    For Example :
    Suppose i have a method1() which has the listener1() get invoked at some operation at line #1 of method();
    The task of listener1() takes 2 minutes aprox.
    Then my question is does method1() waits until listener1() finishes its task(2 Minutes) ?
    What is he default behavior of listner1()
    Can we change the default behavior of custom listners ?
    Thanks & Regards,

    jwenting wrote:
    rephrase your question in gramatically (and preferably syntactically) correct English so people can actually understand what you're asking.You took the words straight out of my mouth
    Mel

  • Event Listening With Correlation

    Hi.
    I am seeking the better solution for listening to an event based in information that each BPEL process instance stores internally.
    To each BPEL instance is passed a correlation ID, that is not unique among several BPEL instances. I want to cancel the corresponding BPEL instances if a termination event is published in EDN referring the same correlation ID. The BPEL instances waits for the termination events in a pick activity.
    I have tried 2 solutions:
    1- Filter expression on the event listening on the onMessage branch- The problem is that i cannot acess internal instance data (id that was passed to the instance on the initiate message) to place on the expression. I can build the expression only based on the event data. Makes sense since this test is maybe taking place on the EDN.
    2- Correlation Set on the event listening. The problem is that i get a "receive conflict" since the correlation set is not unique among the instances.
    The workaround was to receive the event in all instances and test the correlation ID subsequently in an "if activity". If the correlation ID is not "mine" i have to listen again. I have to put pick activity inside a while.
    Anybody has faced this requirement?
    Can someone help me with a more elegant solution?
    Thank you very much.
    Bruno Silva

    I think you should use a midware, like CORBA. If your applications are simulations, use pRTI and study some High Level Architecture before. Then your applications can communicate through the midware. This is for programs written on different platforms. Will take you some time..

  • Validators - Event Listening

    I need to change the trigger event for a validator so it
    checks as soon as information is entered in a text area.
    1. Currently I have to click on something else before the
    Validator checks to see if anything is in the text area. I would
    like it to check as soon as data is entered into the text area.
    (like somehow linking it to the dataChange event of the text Area)
    NB The Validator is attached to a custom component that is
    dynamically created when the application is run.
    2. I have a group of labels which change color based on the
    validator when it is clicked on. Likewise each label only updates
    when I click on another label and then click back on the original
    label. I am somewhat new to Flex 2 so I am a bit confused about how
    event listening works and how events can be handled.
    My code follows below:
    // Event listener for the valid and invalid events - in
    script
    public function
    handleValid(eventObj:ValidationResultEvent):Boolean
    if(eventObj.type==ValidationResultEvent.VALID){
    isValid = true;
    else
    isValid = false;
    return isValid;
    // Constructor
    <mx:Validator id="reqValid" required="true"
    source="{feedbackText}" property="text"
    valid="handleValid(event)" invalid="handleValid(event)"/>

    I think you should use a midware, like CORBA. If your applications are simulations, use pRTI and study some High Level Architecture before. Then your applications can communicate through the midware. This is for programs written on different platforms. Will take you some time..

  • ActiveJMS Java Bean Bridge - VB6 - ActiveX event listener

    I tried to run a simple ActiveJMS client in VB6 with SUN's broker. All steps have been successful until trying to compile and run the ActiveX in VB6 code.
    1) ************************************************************************************
    Code from the ActiveJMS samples (below): Compiles, but runtime error '429' on the 'Set' statement.
    Option Explicit
    Private WithEvents objActiveJMS As ActiveJMS.ActiveJMS
    Private Sub Form_Load()
    Set objActiveJMS = New ActiveJMS.ActiveJMS
    End Sub
    2) ************************************************************************************
    Changing the declaration and creation of objActiveJMS (below) made the application run until the event listener call. And then stop there with a runtime error 'java.lang.NoClassDefFoundError : org.activejms/ActiveJMS$2' .
    Option Explicit
    Dim objActiveJMS As Object
    Private Sub Form_Load()
    Set objActiveJMS = CreateObject("ActiveJMS.Bean.1")
    lngProvider = objActiveJMS.getProvider("${default}")
    lngConnectionFactory = objActiveJMS.lookupOnProvider(lngProvider, "EMERGENSYS")
    lngConnection = objActiveJMS.createTopicConnectionOnTopicConnectionFactory(lngConnectionFactory, "admin", "admin")
    lngReceiveSession = objActiveJMS.createTopicSessionOnTopicConnection(lngConnection, False, objActiveJMS.AutoAcknowledgeOnSession)
    lngTopic = objActiveJMS.createTopicOnTopicSession(lngReceiveSession, "MCAD")
    lngReceiver = objActiveJMS.createSubscriberOnTopicSession(lngReceiveSession, lngTopic, "", False)
    objActiveJMS.activateMessageListenerOnMessageConsumer lngReceiver
    objActiveJMS.startOnConnection (lngConnection)
    End Sub
    3) ***********************************************************************************
    - I did not use the .tbl file ; It has not been generated by packager.
    - I did also not use -clsid and -reg packager options.
    - I have been able to generate the .dll fille and register it.
    - I'm using j2sdk/jre 1.4.2_04
    Thanks in advance.

    I tried to run a simple ActiveJMS client in VB6 with SUN's broker. All steps have been successful until trying to compile and run the ActiveX in VB6 code.
    1) ************************************************************************************
    Code from the ActiveJMS samples (below): Compiles, but runtime error '429' on the 'Set' statement.
    Option Explicit
    Private WithEvents objActiveJMS As ActiveJMS.ActiveJMS
    Private Sub Form_Load()
    Set objActiveJMS = New ActiveJMS.ActiveJMS
    End Sub
    2) ************************************************************************************
    Changing the declaration and creation of objActiveJMS (below) made the application run until the event listener call. And then stop there with a runtime error 'java.lang.NoClassDefFoundError : org.activejms/ActiveJMS$2' .
    Option Explicit
    Dim objActiveJMS As Object
    Private Sub Form_Load()
    Set objActiveJMS = CreateObject("ActiveJMS.Bean.1")
    lngProvider = objActiveJMS.getProvider("${default}")
    lngConnectionFactory = objActiveJMS.lookupOnProvider(lngProvider, "EMERGENSYS")
    lngConnection = objActiveJMS.createTopicConnectionOnTopicConnectionFactory(lngConnectionFactory, "admin", "admin")
    lngReceiveSession = objActiveJMS.createTopicSessionOnTopicConnection(lngConnection, False, objActiveJMS.AutoAcknowledgeOnSession)
    lngTopic = objActiveJMS.createTopicOnTopicSession(lngReceiveSession, "MCAD")
    lngReceiver = objActiveJMS.createSubscriberOnTopicSession(lngReceiveSession, lngTopic, "", False)
    objActiveJMS.activateMessageListenerOnMessageConsumer lngReceiver
    objActiveJMS.startOnConnection (lngConnection)
    End Sub
    3) ***********************************************************************************
    - I did not use the .tbl file ; It has not been generated by packager.
    - I did also not use -clsid and -reg packager options.
    - I have been able to generate the .dll fille and register it.
    - I'm using j2sdk/jre 1.4.2_04
    Thanks in advance.

Maybe you are looking for

  • I can no longer get Firefox to work. I tried to update it but it won't complete configuration.

    Firefox notified me of an upgrade, so when I went to upgrade, now Firefox won't work at all. It would not complete the configuration on my Mac. The Firefox icon now has a big circle with the line through it. the error message number is 10661.

  • Thunderbolt to FW800 to FW400...

    Here's the deal... I have brand new Mac, with Thunderbolt and Presonus Firestudio 2626 audio interface with FW400 connections. Now... I got Thunderbolt to FW800 adapter, FW800 to FW400 cable, and here this gets interesting... My Mac won't find this i

  • WSW0100: Unable to create Service

    Hi, I am trying to access a webservice(Location.jws) via a dataservice function(GetLocationResponse.ds) The primary objective of the webservice is to post a request to GlobalLocate, a location provider and obtain the user's location co-ordinates. On

  • Traxkpoint press_to_select by default in LXDM

    I want to enable "press_to_select" for my trackpoint by default while booting and disable the touchpad at the some time. I use LXDM so I added echo -n 1 | tee /sys/devices/platform/i8042/serio1/serio2/press_to_select synclient TouchpadOff=1 & to /etc

  • Easiest way to use multiple computers for render/export?

    So, for tools like Vegas, Premiere etc you can have a render far, that would help you render/export clips potentially cutting down render time from 40+ hours to mere hour or two. I have a couple of macs available on the network that i would like to t