Listening for click event

I am curious, how can you have a child mxml page listen for
an event from the parent?
Let's say you have a button, call it 'btn1' on page1.mxml and
you want to listen for the click event on page2.mxml. So far this
is what I have:
page1.mxml:
<mx:Button id="btn1" />
page2.mxml:
<mx:Script>
<![CDATA[
private function btnListener(e:MouseEvent){
Application.application.btn.addEventListener(MouseEvent.CLICK,
setState(1));
]]>
</mx:Script>

"spacehog" <[email protected]> wrote in
message
news:glljts$g04$[email protected]..
>I am curious, how can you have a child mxml page listen
for an event from
>the
> parent?
>
> Let's say you have a button, call it 'btn1' on
page1.mxml and you want to
> listen for the click event on page2.mxml. So far this is
what I have:
>
> page1.mxml:
>
> <mx:Button id="btn1" />
>
> page2.mxml:
>
> <mx:Script>
> <![CDATA[
>
>
> private function btnListener(e:MouseEvent){
>
Application.application.btn.addEventListener(MouseEvent.CLICK,
> setState(1));
> }
> ]]>
> </mx:Script>
Check out Q3:
http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf

Similar Messages

  • Listening for click event on an af:image tag

    Dear All,
    Can anybody help me why my code does not work.
    Use case, using an Image, i wanted to call a managed bean method whenever I clicked the image. So here is what I did, I added a clientlistner
    and wait for the click event. Also a server listener is attached to the image.
    <af:image >
         <af:clientListener type="click" method="handleImageClick"/>
         <af:serverListener type="ImageEvent"
                           method="#{viewScope.MyBean.handleImageEvent}"/>
    </af:image>...and here is my javascript...
    <f:facet name="metaContainer">
         <af:resource type="javascript">
           function handleImageClick(evt)
                var comp = evt.getSource();
                AdfCustomEvent.queue(comp, "ImageEvent",{ fvalue : comp.getSubmittedValue()},false);
                evt.cancel();
         </af:resource>
    </f:facet>..and here is my managed bean method.
    public void handleImageEvent(ClientEvent ce)
    }I jsut dont know why it does not call my managed bean method. Is there any mistake in my code?
    JDEV 11G PS5
    Thanks

    codigoadf wrote:
    the problem is in Javascript. remove "fvalue : comp.getSubmittedValue()" and will work fine.
    AdfCustomEvent.queue(comp, "ImageEvent",{ },false);comp.getSubmittedValue()?? comp is a imageAhhh yeah..I just copy pasted this code from google..
    Thanks for your help...it now works..

  • Dispatching & listening for custom events from custom component [Flex 4.1]

    I'm giving this a try for the first time and I'm not sure I have the recipe correct!
    I have a custom component - it contains a data grid where I want to double click a row and dispatch an event that a row has been chosen.
    I created a custom event
    package oss
        import flash.events.Event;
        public class PersonChosenEvent extends Event
            public function PersonChosenEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
                super(type, bubbles, cancelable);
            // Define static constant.
            public static const PERSON_CHOSEN:String = "personChosen";
            // Define a public variable to hold the state of the enable property.
            public var isEnabled:Boolean;
            // Override the inherited clone() method.
            override public function clone():Event {
                return new PersonChosenEvent(type);
    Then I try to dispatch the event within the component when the datagrid is doubleclicked:
    import oss.PersonChosenEvent
    dispatchEvent(new PersonChosenEvent(PersonChosenEvent.PERSON_CHOSEN, true, false));
    And in the parent application containing the component I do on creationComplete
    addEventListener(PersonChosenEvent.PERSON_CHOSEN,addPersonToList);
    The event does not seem to fire though. And if I try to evaluate the "new PersonChosenEvent(..." code it tells me "no such variable".
    What am I doing wrong?
    (It was so easy in VisualAge for Java, what have we done in the last 10 years?? )
    Martin

    I've done this kind of thing routinely, when I want to add information to the event.  I never code the "clone" method at all.
    Be sure that you are listening to the event on a parent of the dispatching component.
    You can also have the dispatching component listen for the event too, and use trace() to get a debug message.
    I doubt if it has anything to to with "bubbles" since the default is true.
    Sample code
    In a child (BorderContainer)
    dispatchEvent(new ActivationEvent(ActivationEvent.CREATION_COMPLETE,null,window));
    In the container parent (BorderContainer)
    activation.addEventListener(ActivationEvent.CREATION_COMPLETE,activationEvent);
    package components.events
        import components.containers.SemanticWindow;
        import components.triples.SemanticActivation;
        import flash.events.Event;
        public class ActivationEvent extends Event
            public static const LOADED:String = "ActivationEvent: loaded";
            public static const CREATION_COMPLETE:String = "ActivationEvent: creation complete";
            public static const RELOADED:String = "ActivationEvent: reloaded";
            public static const LEFT_SIDE:String = "ActivationEvent: left side";
            public static const RIGHT_SIDE:String = "ActivationEvent: right side";
            private var _activation:SemanticActivation;
            private var _window:SemanticWindow;
            public function ActivationEvent(type:String, activation:SemanticActivation, window:SemanticWindow)
                super(type);
                _activation = activation;
                _window = window
            public function get activation():SemanticActivation {
                return _activation;
            public function get window():SemanticWindow{
                return _window;

  • Listening for an event outside of the object...

    Hey, I spent a lot of my day trying to figure out how to
    listen for an event outside of an instantiated object of my own.
    I made my own class called
    Link. When my Link class is instantiated, a Loader object
    (var loader:Loader) is added and it loads a user-specified external
    PNG file. I want to track the Event.COMPLETE event OUTSIDE of my
    Link class, like in my FLA's Actionscript.
    So, I tried a few things without any luck, and by these you
    might get the idea of exactly what I'm trying to do:
    var link1:Link = new Link(...);
    link1.loader.addEventListener(Event.COMPLETE, handler);
    That didn't work, so I tried:
    var link1.Link = new Link(...);
    var loader = link1.getChildByName("loader") as Loader;
    loader.addEventListener(Event.COMPLETE, handler);
    ... that didn't work either. :(
    Any ideas?
    If I am taking the completely wrong approach please do let me
    know. If there's ANY way to know WHEN my loader has completed
    loading its image outside of my Link class...
    Thanks!
    ~ Andrew Merskin

    Let your Link class handle the Loader events. When
    Event.COMPLETE fires,
    just redispatch the event or dispatch a custom event.
    Example 1:
    link1.addEventListener("ALLDONELOADING", linkEventHandler);
    function linkEventHandler(event:Event)
    if(event.type == "ALLDONELOADING")
    // do something or nothing at all
    // Inside your link class you are listening for the load
    complete
    function loadCompleteHandler(event:Event)
    dispatchEvent(new Event("ALLDONELOADING")));
    Example 2:
    link1.addEventListener(Event.COMPLETE, linkEventHandler);
    function linkEventHandler(event:Event)
    if(event.type == Event.COMPLETE)
    // do something or nothing at all
    // Inside your link class you are listening for the load
    complete
    function loadCompleteHandler(event:Event)
    dispatchEvent(event);

  • How to create many objects listening for one event

    I'm experimenting with the EventDispatcher class and I have a
    test class working. I want to use a loop to create a variety of
    movie clips that all listen for an event that gets dispatched every
    half a second. I have the event dispatching properly. My problem is
    that when creating the objects, the temporary variable I use to
    hold each created object has a life that extends beyond the loop in
    which it is instantiated. Rather than all five created objects
    changing color, only the last one changes color (see the code
    below--it lives on the first frame of an FLA file).
    This is not entirely surprising when I look at the code --
    'this' refers to the global scope and 'square' refers to the last
    created object that it pointed to. Here's the resulting trace:
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    How can I modify this code so that each square object changes
    its own color?

    graphics.clear in the context of that function handler in my
    code would refer not to the squares but to the global scope,
    wouldn't it? In which case you'd be clearing all the graphics from
    your top level movie. I tried changing 'square.graphics' to just
    'graphics' in my handler and my squares just remained the original
    steady black.
    Your code doesn't use a loop and therefore isn't re-using a
    variable. You've escaped my 'logical errors' through brute force.
    (BTW, I think my code would work in AS2 if I used the old-school
    draw methods). Suppose you had to create 100 objects? Would you
    want to manually instantiate each one, typing that function over
    and over again? You'd have 500 lines of highly redundant code!
    Maybe try your example using a loop instead? I think you'll
    find it's pretty tough to sneak any vars like 'i' or 'square' from
    the global scope into the handler--the handler refers to the
    living, breathing variable rather than it's value at the time the
    handler was instantiated. Furthermore, you can't sneak any
    information about the square into your handler via the event object
    because the event object is created in a totally different place.

  • Listening for keyPressed events from background?

    Is it possible to have a java program running in the background and listen for keyPressed events? I would like for the program to listen for certain keys to be pressed and when they are manipulate the mouse. From what I've looked at so far however it seems the listening component must have focus. Thanks.

    On any OS that would typically involve hooking into the OS itself.
    And then manipulating OS resources as well.
    Putting an app into the 'background' is also OS specific.
    Given that the above is all you want to do then java is not an appropriate language choice. C++ would be better.

  • Component listening for a event

    I need to make 1 component listen for an event in another component..
    JMenuItem listens for a TreeSelectionEvent and in case something selected enables... and disables otherwise...
    addTreeSelectionListener() is not possible for a JMenuItem component...
    so how do i do that?
    the code below is not acceptable because there is a lot of JMenuItem objects and it's a bit messy and difficult to add each...
    tree.addTreeSelectionListener(blah) {
    JMenuItem.setEnabled(false);
    i want a component checking himself for a proper condition...
    in case it will require too much hardware resourses what would you suggest?

    Do you ever get to a point in programming where you think that perhaps i have choosen the wrong hobby to get infatuated about
    That code worked really well targetplanet but it had a side effect that just makes me nutts lol
      as it triggered a mouse event function in the component that was initialized in Main and just made my web site go nuts . the component that we initialized was a skin but its itemRenderer component that followed had the mouse event! perhaps i better start again with me learning perhaps i missed something
    or perhaps i should just have one component to one job instead of trying to be clever and mutitask with less components!

  • Listening for an event in main from a component

    Hi
    Ok so i have a Flash Builder project 4.5 that i created in Flash Catalyst thats draws all its data from MySql and four months into the build, as this is my first web project im noticing that when the page loads up in the browser it loads everything at once! and as im hoping to reuse some of the same components for diffrent tasks i assume that if i put the data retrivail under events that happen within the web page this will hopeful control the data flow as well as showing the correct data depending on CurrentState!
    The problem that im having is that my buttons are in my Main Application and the data retrival process is in my components! so i was trying to create addEventListener(MouseEvent.CLICK events in a component that was listening for events in my Main application. i have search the internet but every one is talking about the process in the main or component but not both!
    Does anyone know what im talking about and could you please share some light please

    Do you ever get to a point in programming where you think that perhaps i have choosen the wrong hobby to get infatuated about
    That code worked really well targetplanet but it had a side effect that just makes me nutts lol
      as it triggered a mouse event function in the component that was initialized in Main and just made my web site go nuts . the component that we initialized was a skin but its itemRenderer component that followed had the mouse event! perhaps i better start again with me learning perhaps i missed something
    or perhaps i should just have one component to one job instead of trying to be clever and mutitask with less components!

  • Opening New Browser window for click event on an image

    hi all,
    I want someone to help me out solving the problem of opening
    a new browser window on the mouse click event of an image or a
    button etc.... The new window would contain the datagrid details
    from the main window, but in an expanded form. If at all there is a
    solution, I even want to know whether there is anyway for sizing
    the poped up window,because I dont want the new poped up window to
    cover the entire screen.
    For getting better idea of my problem, the best example I
    could give is the popup window that appears when we click on the
    preview button while posting the message to the forum.
    Someone please do help me out in this regard.
    Thanks,
    amar.

    I'd definitely try to use a Flex popup... but the
    flash.net.navigateToURL method is a simple way to open a popup
    window in a new browser. You can pass any data needed by the new
    page using the URLRequest and/or URLVariables. The URL you navigate
    to could, of course, be another Flex application if necessary. I
    use this only when I need to open a popup window on another site,
    or an HTML formatter report or something similar.
    Concerning yourself with the size of the popup window may be
    a bad design choice also. I, for example, have my browser
    configured to open all popups in a new tab regardless of sizing
    constraints imposed by the designer. If it is absolutely necessary
    for you to have control over the size of your popup window, you
    should follow the advice given by others and use a Flex
    popup.

  • Listen for an events for Swing objects in a separate class?

    Hi all, sorry if this is in the wrong section of the forum but since this is a problem I am having with a Swing based project I thought i'd come here for help. Essentially i have nested panels in separate classes for the sake of clarity and to follow the ideas of OO based development. I have JPanels that have buttons and other components that will trigger events. I wish for these events to effect other panels, in the Hierachy of my program:
    MainFrame(MainPanel(LeftPanel, RightPanel, CanvasPanel))
    Sorry I couldnt indent to show the hierarchy. Here LeftPanel, RightPanel and CanvasPanel are objects that are created in the MainPanel. For example i want an event to trigger a method in another class e.g. LeftPanel has a button that will call a method in CanvasPanel. I have tried creating an EventListner in the MainPanel that would determine the source and then send off a method to the relevant class, but the only listeners that respond are the ones relevant to the components of class. Can I have events that will be listened to over the complete scope of the program? or is there another way to have a component that can call a method in the class that as an object, it has been created in.
    Just as an example LeftPanel has a component to select the paint tool (its a simple drawing program) that will change a color attribute in the CanvasPanel object. Of course I realize i could have one massive Class with everything declared in it, but I'd rather learn if it is possible to do it this way!
    Thanks in advance for any help you can offer
    Lawrence
    Edited by: insertjokehere on Apr 15, 2008 12:24 PM

    Thanks for the response, ive added ActionListneres in the class where the component is, and in an external class. The Listeners work inside the class, but not in the external class
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    public class LeftPanel extends JPanel implements ActionListener {  
        /* Constructing JButtons, null until usage of the constructor */
        JButton pencilBut;
        JButton eraserBut;
        JButton textBut;
        JButton copyBut;
        JButton ssincBut;
        JButton ssdecBut;
        ActionListener a = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.print("\nNot supported yet.");
        /* The Top Panel contains the title of program */
        public LeftPanel(Dimension d){
            /* Sets up the layout for the Panel */
            BoxLayout blo = new BoxLayout(this,BoxLayout.Y_AXIS);
            this.setLayout(blo);
            /* Sets Up the Appearance of the Panel */
            this.setMinimumSize(d);
            this.setBackground(Color.RED);
            this.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
            /* Pencil Tool */
            pencilBut = new JButton("Pencil");
            pencilBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            pencilBut.setActionCommand("pencil");
            pencilBut.addActionListener(a);
            this.add(pencilBut);
            /* Eraser Tool */
            eraserBut = new JButton("Eraser");
            eraserBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            eraserBut.addActionListener(a);
            this.add(eraserBut);
            /* Text Tool */
            textBut = new JButton("Text");
            textBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            textBut.addActionListener(a);
            this.add(textBut);
            /* Copy Previous Page */
            copyBut = new JButton("Copy Page");
            copyBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            copyBut.addActionListener(a);
            this.add(copyBut);
            /* Stroke Size Increase */
            ssincBut = new JButton("Inc");
            ssincBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            ssincBut.addActionListener(a);
            this.add(ssincBut);
            /* Stroke Size Decrease */
            ssdecBut = new JButton("Dec");
            ssdecBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            ssdecBut.addActionListener(a);
            this.add(ssdecBut);
            System.out.print("\nLeftPanel Completed");
        public void actionPerformed(ActionEvent e) {
            System.out.print("\nAction Performed");
        }But this is not picked up in my external class here
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    public class MainPanel extends JPanel implements ActionListener {
        /* Creates a new the main JPanel that is used in the FlipBookFrame to contain all of the elements */
        public MainPanel(){
            /* TopPanel constraints*/
            tpcs.gridx = 1;
            tpcs.gridy = 0;
            tpcs.gridwidth = 1;
            tpcs.gridheight = 1;
            tpcs.fill = GridBagConstraints.BOTH;
            tpcs.weightx = 0.0;
            tpcs.weighty = 1.0;
            /* LeftPanel Constraints*/
            lpcs.gridx = 0;
            lpcs.gridy = 0;
            lpcs.gridwidth = 1;
            lpcs.gridheight = 3;
            lpcs.fill = GridBagConstraints.BOTH;
            lpcs.weightx = 1.0;
            lpcs.weighty = 1.0;
            /* CentrePanel Constraints*/
            cpcs.gridx = 1;
            cpcs.gridy = 1;
            cpcs.gridwidth = 1;
            cpcs.gridheight = 1;
            cpcs.fill = GridBagConstraints.NONE;
            cpcs.weightx = 0.0;
            cpcs.weighty = 0.0;
            /* RightPanel Constraints*/
            rpcs.gridx = 2;
            rpcs.gridy = 0;
            rpcs.gridwidth = 1;
            rpcs.gridheight = 3;
            rpcs.fill = GridBagConstraints.BOTH;
            rpcs.weightx = 1.0;
            rpcs.weighty = 1.0;
            /* BottomPanel Constraints*/
            bpcs.gridx = 1;
            bpcs.gridy = 2;
            bpcs.gridwidth = 1;
            bpcs.gridheight = 1;
            bpcs.fill = GridBagConstraints.BOTH;
            bpcs.weightx = 0.0;
            bpcs.weighty = 1.0;   
            this.setLayout(gblo);   //Sets the Layout of the panel to a GridBagLayout
            this.add(tp, tpcs); //Adds the TopPanel to the MainPanel using the TopPanel layout
            this.add(lp, lpcs); //Adds the LeftPanel to the MainPanel using the LeftPanel layout
            this.add(cp, cpcs); //Adds the CanvasPanel to the MainPanel using the CanvasPanel layout
            this.add(rp, rpcs); //Adds the RightPanel to the MainPanel using the RightPanel layout
            this.add(bp, bpcs); //Adds the BottomPanel to the MainPanel using the BottomPanel layout
            gblo.layoutContainer(this); //Lays Out the Container
        public PanelSizes getPanelSizes(){
            return ps;
        public void actionPerformed(ActionEvent e) {
            System.out.print("\nExternal Class finds event!");
            /*String command = e.getActionCommand();
            if (command.equals("pencil")){
                System.out.print("\nYESSSSSSSSSSSSSSSSSSSSS!");
        /* Create of objects using the PanelSizes funtions for defining the */
        PanelSizes ps = new PanelSizes();   //Creates a new PanelSizes object for sizing the panel
        CanvasPanel cp = new CanvasPanel(ps.getCentrePanelDimension()); //Creates a new Canvas Panel
        TopPanel tp = new TopPanel(ps.getHorizontalPanelDimension()); //Creates the TopPanel
        BottomPanel bp = new BottomPanel(ps.getHorizontalPanelDimension()); //Creates the BottomPanel
        LeftPanel lp = new LeftPanel(ps.getVerticalPanelDimension()); //Creates the LeftPanel
        RightPanel rp = new RightPanel(ps.getVerticalPanelDimension());   //Creates the RightPanel
        /* I have chosen to create individual constraints for each panel to allow for adding of all
         components a the end of the constructor. This will use slightly more memory but gives clarity
         in the code */
        GridBagConstraints cpcs = new GridBagConstraints();
        GridBagConstraints tpcs = new GridBagConstraints();
        GridBagConstraints bpcs = new GridBagConstraints();
        GridBagConstraints lpcs = new GridBagConstraints();   
        GridBagConstraints rpcs = new GridBagConstraints();
        GridBagLayout gblo = new GridBagLayout();
    }Any help will be greatly appreciated :-)

  • Listener for dispatched event

    Hi,
    I had a problem which the majority of got sorted out with
    help from other people but it's left me with one last part i dont
    get...
    I have a main.swf which loads into a loader an external swf
    called menu1.swf. I'm trying to get a function triggered in the
    main.swf when it recieves an event dispatched from the menu1.swf.
    The main problem i had was getting the event to dispatch from the
    loaded swf but that's now sorted. My main problem now is where to
    add the listener in the main.swf to listen out for this event.
    I've been informed it's not the loader i should be attaching
    the listener to, but rather it's contents ( the function i want to
    call is to unload the loader once the event from the contents of
    that loader has been dispatched). Now the contents is menu1.swf,
    but i didnt think you could attach a listener to a swf? I was also
    told that once the loader has completed loading, the swf is no
    longer a swf, but instead becomes content.data...
    So what am i attaching a listener to? should it be
    loader.content.data.addEventlistener(... );
    it's got me stumped?

    Hi kglad - thanks for the reply.
    Just want to point out im using the TweenMax engine to call
    the function which will dispatch the event in the loaded.swf.
    I've added the code you suggested to the loaderComplete
    function in my main.swf script like you suggested ( to guarantee
    their be some content in the loader) and got this:
    TypeError: Error #1034: Type Coercion failed: cannot convert
    flash.events::Event@4097da9 to flash.events.MouseEvent.
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at menu_1/menu_1::callUnload()[C:\Users\andrew\Desktop\New
    Folder (2)\work\menu_1.as:164]
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at
    gs::TweenLite/complete()[C:\Users\andrew\Desktop\flash\actionscripts\gs\TweenLite.as:416]
    at
    gs::TweenFilterLite/render()[C:\Users\andrew\Desktop\flash\actionscripts\gs\TweenFilterLi te.as:361]
    at
    gs::TweenLite$/executeAll()[C:\Users\andrew\Desktop\flash\actionscripts\gs\TweenLite.as:3 95]
    dont suppose you know what all that means do you? I've read
    that theirs a bug in the onComplete tween of the TweenMax engine -
    any chance that's what this is at all?...

  • Listening for change events on a JTable

    Hi
    me = Java newbie!
    Well I've been building an app to read EXIF data from JPEG files using the imageio API and Swing. Learning both along the way.
    Stumbling block is that I am outputting the EXIF data into a JTable, inside a JScrollPane. These 2 components then become associated with a JInternalFrame container of the class MyInternalFrame.
    Works!
    Next job is to enable user to select a row in the table which then displays the image file.
    I know I can use ListSelectionEvent to detect a row selection and that 2 events are fired.
    I put some code into MyInternalFrame class to register a ListSelectionEvent, but I can't see how to reference MyInternalFrame from within this code....see below:
    package EXIFReader;
    import java.io.File;
    import java.io.FilenameFilter;
    import javax.swing.JInternalFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    //This class constructs a table and displays it in a JInternalFrame
    public class MyInternalFrame extends JInternalFrame {
    static int openFrameCount = 0;
    static final int xOffset = 30, yOffset = 30;
    File file;
    File[] directoryMembers = null;
    public MyInternalFrame(File aFile) { //aFile rererences a directory containing jpeg files//
    super(null,
    true, //resizable
    true, //closable
    true, //maximizable
    true);//iconifiable
    file = aFile;
    //Set the window's location.
    this.setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    FilenameFilter filter = new FilenameFilter() {
    public boolean accept(File dir, String name) {
    return name.endsWith(".jpg");}};//Filter out any files in the directory that ain't jpegs
    directoryMembers = file.listFiles(filter);
    int i = 0;
    String[][] tableData= new String [directoryMembers.length][5];
    String[]headers = new String[]{"File Name","Date Taken",
    "F-Number","Exposure",
    "Flash Settings"};
    for (File dirfile: directoryMembers)
    try {
    if(dirfile!=null){
    tableData[i] = new ExifReader(dirfile).getEXIFData();//populate the table with jpeg file names
    i++;}}
    catch (Exception ex) {
    System.out.print("Error" + ex);
    if (tableData[0] != null){
    final JTable myTable = new JTable(tableData,headers);
    this.setSize(900,(50+(directoryMembers.length)*19));
    myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(new JScrollPane(myTable),"Center");//add the JTable and JScrollPanel to this MyInternal Frame and display it! - cool it works!
    ListSelectionModel myLSM = myTable.getSelectionModel();
    myLSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent le) {
    int[] rows = myTable.getSelectedRows();//want to respond to selections and then display the image as a JInternalFrame but got confused about references from within this listener - need help!
    Any gentle nudges?!
    P
    I can respond to these events using a JFrame, but how can I display the image in a JInternalFrame?

    Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
    To get better help sooner, post a [_SSCCE_|http://mindprod.com/jgloss/sscce.html] that clearly demonstrates your problem.
    db

  • Create Component that Listens for Custom Event

    I've read a lot of tutorials and posts in this forum but still seem to be missing something.
    I want to be able to create an arbitrary number of instances of a custom class (based on Button) that each listen to a custom event dispatched in the application.  Eventually the event will carry data (including information that will let each Button determine whether it should react to the event), but for now I just want them to be able to hear the event.
    What's supposed to happen is
    1) Clicking the button labeled "I Make the Button" creates an instance of EventHearingButton using this.addElement.
    2) Clicking the button labeled "I Send the Event" dispatches the SuperCustomEvent custom event, with the additional information "I heard that" stored in the Information string
    3) The created EventHearingButton hears the event and updates its label to the value in the Information string.
    What actually happens is the EventHearingButton is created OK, but nothing happens when the "I Send the Event" button is clicked.
    Main.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/halo">
         <fx:Metadata>
              [Event(name="SuperCustomEvent", type="Classes.SuperCustomEvent")]
         </fx:Metadata>
         <fx:Script>
              <![CDATA[
                   import Classes.EventHearingButton;
                   import Classes.SuperCustomEvent;
                   protected function EventDispatcherButton_clickHandler(event:MouseEvent):void
                        var NewEvent:SuperCustomEvent = new SuperCustomEvent("I heard that");
                        this.dispatchEvent(NewEvent);
                   protected function button1_clickHandler(event:MouseEvent):void
                        var NewButton:EventHearingButton = new EventHearingButton();
                        NewButton.x=270;
                        NewButton.y=130;
                        this.addElement(NewButton);
              ]]>
         </fx:Script>
         <s:Button x="270" y="90" label="I Send The Event" id="EventDispatcherButton" click="EventDispatcherButton_clickHandler(event)"/>
         <s:Button x="270" y="50" label="I Make the Button" click="button1_clickHandler(event)"/>
    </s:Application>
    Classes.EventHearingButton.as
    package Classes
         import spark.components.Button;
         import flash.events.Event;
         import Classes.SuperCustomEvent;
         public class EventHearingButton extends Button
              public function EventHearingButton()
                   super();
                   this.label="I haven't heard yet";
                   this.addEventListener(SuperCustomEvent.SUPERCUSTOMEVENT,SuperCustomEventHandler);
              private function SuperCustomEventHandler(event:SuperCustomEvent):void {
                   this.label=event.EventInformation;
    Classes.SuperCustomEvent.as
    package Classes
         import flash.events.Event;
         public class SuperCustomEvent extends Event
              public var EventInformation:String;
              public static const SUPERCUSTOMEVENT:String = "SuperCustomEvent";
              public function SuperCustomEvent(Information:String)
                   super(SuperCustomEvent.SUPERCUSTOMEVENT, true);
                   this.EventInformation=Information;
              override public function clone():Event{
                   return new SuperCustomEvent(EventInformation);

    "nikos101" <[email protected]> wrote in
    message
    news:ga59t5$8nh$[email protected]..
    >I tried something like what AMy described in a custom
    component
    >
    > dispatchEvent(new Event("Cancelled_Form"));
    >
    > I then added the following Listener in my application
    file;
    >
    > this.addEventListener("Cancelled_Form",cancelledForm);
    >
    > but it is never heard. Does anyone know what I have done
    wrong?
    Try attaching the event listener to your component rather
    than the
    application.
    HTH;
    Amy

  • MenuBar Component: Listener for Click on Main Menu?

    When using the MenuBar component, is there a way to add an
    event that will tirgger when the user clicks an item in the MenuBar
    (as differentiated from when they click on a sub-menu item)?

    If you removed the stop() from scene 2 it will not stop there it will return to wherever "home" is.
    If you intend to have the timeline stop at some frame, then you need to place a stop() command in that frame, or use a gotoAndStop() command.
    If you are going to use scenes  be consistent with the way you write the goto commands. The use of is rarely recommended - instead, use different sections of the timeline of just one scene, or use movieclips and control their visibility, or a combination of both.
    If you continue to have issues, try simplifying first - build/add the navigation for one section at a time instead of trying to get it all in one shot.

  • Stoping a group of child components from listening for mouseover event.

    Hi,
    I am trying to create a type of navigation system in this little app i'm working on which executes a function when the mouse is rolled over a canvas container. There are four of these canvas container which carry child components like labels, image, and text controls. These canvas containers have an initial alpha values of 0.5 so i want the fade effect to gradually animate to 1.0 when the mouse is rolls over it. When the mouse rolls out i want the alpha to animate the alpha values back to 0.5. I have sucessfuly done this here is a sample code.
         public function rollOverEffect(e:Event):void
              var ROFadeEffect:Fade=new Fade(e.target);
              ROFadeEffect.duration=500;
              ROFadeEffect.alphaFrom=0.5;
              ROFadeEffect.alphaTo=1;
              ROFadeEffect.end();
              ROFadeEffect.play([e.target]);
         public function rollOutEffect(e:Event):void
              var ROFadeEffect:Fade=new Fade(e.target);
             ROFadeEffect.duration=500;
              ROFadeEffect.alphaFrom=1;
              ROFadeEffect.alphaTo=0.5;
              ROFadeEffect.end();
              ROFadeEffect.play([e.target]);
    So this is working but not perfect...everytime my mouse rolls over the canvas it comes to life (Fades in).....but when it rolls over its child components, it fades out. I really dont follow why. Do i need to stop these child components from recieving events or what
    here is the MXML code for the UI
         <mx:Canvas  alpha="0.5" id="newMemCanvas" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)"  x="448" y="32" width="252"      height="218" backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Label x="61" y="24" text="New Members" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:Label x="10" y="65" text="0 New Member(s)" fontWeight="normal" fontSize="12" color="#434343"/>
              <mx:Image x="17" y="10" source="resource/studentUser.png" width="36" height="42"/>
              <mx:HRule x="14" y="55" width="226"/>
         </mx:Canvas>
         <mx:Canvas  alpha="0.5" id="recPosted" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" x="448" y="252" width="252"               height="218" backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Label x="42" y="16" text="Recently Posted" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:Label x="14" y="65" text="No Post Yet!" fontWeight="normal" fontSize="12" color="#434343"/>
              <mx:Image x="10" y="10" source="resource/blog_post_new.png"/>
              <mx:HRule x="10" y="51" width="226"/>
         </mx:Canvas>
         <mx:Canvas  alpha="0.5" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" x="702" y="32" width="252" height="218"      backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Label x="78" y="23" text="Unread Messages" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:Label x="17" y="64" text="0 Unread Message(s)" fontWeight="normal" fontSize="12" color="#434343"/>
              <mx:HRule x="14" y="54" width="226"/>
              <mx:Image x="10" y="20" source="resource/unreadMess.png" width="60" height="30"/>
         </mx:Canvas>
         <mx:Canvas  alpha="0.5" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" x="703" y="253" width="248" height="218"      backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Image x="10" y="10" source="resource/mainLogo.png" width="41" height="35"/>
              <mx:Label x="55" y="18" text="Guided Tours" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:HRule x="11" y="51" width="226"/>
              <mx:Label x="10" y="66" text="Tower Building Video" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Label x="10" y="89" text="Student Interviews" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Label x="10" y="111" text="Social Events" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Label x="10" y="132" text="Living the School Life" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
         </mx:Canvas>
    ...any help will be greatly appreciated...thanx                                                                                    

    Hi l33tian,
    Check the below code with small modifications that I have made to your code in order to make it work...
    Observe the changes that I have made in your rollOver and rollOut functions and also in the mxml code in which I have taken a seperate canvas for all the canvases and added the mouseOver and mouseOut events on this canvas instead of outer canvas so that we can eliminte the problem of FadeOut when we mouseOver on the child components of canvas...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
    <mx:Script>
      <![CDATA[
       import mx.effects.Fade;
       import mx.controls.Alert;
       public function rollOverEffect(e:Event):void
                var ROFadeEffect:Fade=new Fade(e.currentTarget.parent);
                ROFadeEffect.duration=500;
                ROFadeEffect.alphaFrom=0.5;
                ROFadeEffect.alphaTo=1;
                ROFadeEffect.end();
                ROFadeEffect.play([e.currentTarget.parent]);
           public function rollOutEffect(e:Event):void
               var ROFadeEffect:Fade=new Fade(e.currentTarget.parent);
               ROFadeEffect.duration=500;
               ROFadeEffect.alphaFrom=1;
                ROFadeEffect.alphaTo=0.5;
                ROFadeEffect.end();
                ROFadeEffect.play([e.currentTarget.parent]);
      ]]>
    </mx:Script>
    <mx:Canvas  alpha="0.5" id="newMemCanvas" x="448" y="32" width="252" height="218" backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Label x="61" y="24" text="New Members" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:Label x="10" y="65" text="0 New Member(s)" fontWeight="normal" fontSize="12" color="#434343"/>
              <mx:Image x="17" y="10" source="resource/studentUser.png" width="36" height="42" maintainAspectRatio="false"/>
              <mx:HRule x="14" y="55" width="226"/>
         <mx:Canvas  width="100%" height="100%" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" />
         </mx:Canvas>
         <mx:Canvas  alpha="0.5" id="recPosted" x="448" y="252" width="252" height="218" backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Label x="42" y="16" text="Recently Posted" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:Label x="14" y="65" text="No Post Yet!" fontWeight="normal" fontSize="12" color="#434343"/>
              <mx:Image x="10" y="10" source="resource/blog_post_new.png"/>
              <mx:HRule x="10" y="51" width="226"/>
        <mx:Canvas  width="100%" height="100%" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" />
         </mx:Canvas>
         <mx:Canvas  alpha="0.5" x="702" y="32" width="252" height="218"      backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Label x="78" y="23" text="Unread Messages" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:Label x="17" y="64" text="0 Unread Message(s)" fontWeight="normal" fontSize="12" color="#434343"/>
              <mx:HRule x="14" y="54" width="226"/>
              <mx:Image x="10" y="20" source="resource/unreadMess.png" width="60" height="30"/>
        <mx:Canvas  width="100%" height="100%" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" />
         </mx:Canvas>
         <mx:Canvas  alpha="0.5" x="703" y="253" width="248" height="218"      backgroundColor="#FBFBFB" borderColor="#15B5F7" borderStyle="solid" borderThickness="1" cornerRadius="4">
              <mx:Image x="10" y="10" source="resource/mainLogo.png" width="41" height="35"/>
              <mx:Label x="55" y="18" text="Guided Tours" fontWeight="bold" fontSize="14" color="#0EB6DA"/>
              <mx:HRule x="11" y="51" width="226"/>
              <mx:Label x="10" y="66" text="Tower Building Video" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Label x="10" y="89" text="Student Interviews" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Label x="10" y="111" text="Social Events" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Label x="10" y="132" text="Living the School Life" fontWeight="normal" fontSize="11" color="#434343" textDecoration="underline"/>
              <mx:Canvas  width="100%" height="100%" mouseOver="rollOverEffect(event)" mouseOut="rollOutEffect(event)" />
         </mx:Canvas>
    </mx:Application>
    Check this out and please let me know..
    Thanks,
    Bhasker

Maybe you are looking for