Help with combobox event handling

hey techies
does knw any1 tutorial or where any URL which helps me adding event handling to combobox
iam new at event handling
i tried
jc1.addItemListener(this);
public void itemStateChanged(ItemEvent event)
          if(event.getSource()==jc1)
          System.out.println("hello");
     }is this way correct to specify event handling in combobox
i tired this iam getting NPE like this
Exception in thread "main" java.lang.NullPointerException
at FinalMobile.<init>(FinalMobile.java:213)
at FinalMobile.main(FinalMobile.java:740)
plz jst let me knw and dnt tell me to refer swing tutorial i have been reffering it
any help is appreciated

does knw any1 tutorial or where any URL which helps me adding event handling to comboboxExcuse me, I've told you at least 4 times now to download and read the Swing tutorial which has all this information with working examples. I even provided you with the download link.
How do you have the nerve to say you can't find any tutorial?

Similar Messages

  • Help with ComboBox, datasource from database

    Hi there,
    i am new to Flex technology and desperately need help with
    combobox.
    I have a combobox in my app and the datasource comes from
    MySQL database. I use a PHP script to populate the combobox. Say in
    the datatabse table, I have the following result:
    id name
    1 dog
    2 cat
    3 horse
    In the app, the combobox will have the list as the name of
    the animals: dog, cat, horse. But when the user selects dog, how do
    I get the selected id 1 instead of the label "dog".
    Any help/suggestion will be appreciated.

    Hi again,
    the xml for the combobox datasource is as follows
    <animals>
    <animal>
    <id>1</id>
    <name>dog</name>
    </animal>
    <animal>
    <id>2</id>
    <name>cat</name>
    </animal>
    <animal>
    <id>3</id>
    <name>horse</name>
    </animal>
    </animals>
    and my <mx:HTTPService> is:
    <mx:HTTPService id="dropDown" useProxy="false" url="
    http://localhost/~ronnyk/combobox.php"
    resultFormat="e4x" result="get_drop_down(event)" />
    public function get_drop_down(e:ResultEvent):void{
    var dropArr:XML = e.result as XML;
    cb.dataProvider = dropArr.animal;
    cb.labelField = "name";
    cb.data = "id";
    public function clickme():void{
    txtinput.text = cb.selectedItem as String;
    I can't figure out which part I did wrong, in order to get
    the id instead of the name when the user clicks the button

  • Help with Keyboard Event

    Hi, I am designing a drum machine in flash pro Cs6 actionscript 3.0  and I am trying to add a keyboard event that will trigger a button event that I have all ready created, I can create the event to play the sound but this is not what I want, can I call the click event so the button will move on the key event triggering the sound, here is an example of one of my buttons code... btn, thank you if anyone can help.
    import flash.events.KeyboardEvent;
    playsound2.fla
    playsound with extra functionality:
    textbox added.
    Displays ID3 info of the sound
    btn.addEventListener(MouseEvent.CLICK, playSomeSound);
    function playSomeSound(e:MouseEvent)
              var req:URLRequest = new URLRequest("Savage.mp3");
              var s:Sound = new Sound(req);
              s.addEventListener(Event.COMPLETE, onSoundLoaded);
              s.addEventListener(Event.ID3, onID3Info);
    function onSoundLoaded(event:Event):void
              var localSound:Sound = event.target as Sound;
              localSound.play();
    function onID3Info(e:Event):void
              var id3Props:ID3Info = e.target.id3;
              var sOut:String = txt.text = "";
              for (var propName:String in id3Props)
                        sOut = propName + "=" + id3Props[propName] + "\n";
                        trace(sOut);
                        txt.appendText(sOut);
              txt.text = id3Props.comment;
    var ba:ByteArray = new ByteArray();
    var gr:Sprite = new Sprite();
    gr.x = 5;
    gr.y = 50;
    addChild(gr);
    var time:Timer = new Timer(50);
    time.addEventListener(TimerEvent.TIMER, timerHandler);
    time.start();
    function timerHandler(event:TimerEvent):void
              SoundMixer.computeSpectrum(ba, false);
              var i:int;
              gr.graphics.clear();
              gr.graphics.lineStyle(2, 0xFF0000);
              gr.graphics.beginFill(0x00ff00);
              gr.graphics.moveTo(10, 10);
              //  draw a circle.;
              var w:uint = 15;
              for (i=0; i<512; i+=w)
                        var t:Number = ba.readFloat();
                        var n:Number = (t * 200);
                        gr.graphics.drawCircle(i, 0, -n);

    Thanks, this was the code I added in the end and it works nicely, It covers my sound and id3 aswell as Im displaying lcd text in a dynamic text box.
    stage.addEventListener(KeyboardEvent.KEY_DOWN, btndownKey);
    function btndownKey(event:KeyboardEvent)
              if (event.keyCode == 83)
                        var url:String = "Savage.mp3";
                        var request:URLRequest = new URLRequest(url);
                        var s:Sound = new Sound();
                        s.addEventListener(Event.COMPLETE, completeHandler);
                        s.addEventListener(Event.ID3, onID3Info);
                        s.load(request);

  • Help with ComboBox Selection Update

    Hello,
    I am trying to make this application display all its labels in a different language depending on which locale the user picks from the ComboBox. The variables are being read from the ResourceBundles correctly (see command-line debugging statements) but I cannot get the pane to 'refresh' when the item is selected. I've tried everything I can think of! Please help! :)
    (This assignment was to internationalize a program we wrote for a previous assignment, so this program wasn't originally written to do this. I am trying to add this functionality to my existing project, so it's not ideal).
    Thank you for any advice, help or hints you can give!
    Program(PrjGUI)
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import javax.swing.*;
    import java.text.DateFormat;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.util.Locale;
    import java.util.ResourceBundle;
    import java.util.TimeZone;
    public class PrjGUI extends JFrame
       //**** Instance Variables for both classes
       private JRadioButton optGram, optOz;
       private JTextField txtWeightEnter, txtResult, txtDateTime;
       private JButton cmdConvert;
       private JComboBox comboSelectLocale;
            //arrays--one for combo box list, and the other for values to use when a particular list item is selected
       private String[] localeList = {"English, USA", "Fran\u00E7ais, France", "Espag\u00F1ol, M\u00E9xico"};
       private Locale[] localeCode = {(new Locale("en", "US")), (new Locale("fr", "FR")), (new Locale("es", "MX"))};
       private JLabel lblChoose, lblWeightEnter;
       protected String titleTxt, enterTxt, btnTxt, gramTxt, ozTxt, resultDisplayTxt, localeTimeZone, dateFormat;
       protected ResourceBundle res;
       protected Locale currentLocale;
       //declare Handler Object
       private CmdConvertWeight convertWeight;
       //**************main method******************
       public static void main(String[] args)
          PrjGUI convertWeight1 = new PrjGUI();
       }//end of main******************************
       //constructor
       public PrjGUI()
          //create panel for components
          Container pane = getContentPane();
          //set the layout
          pane.setLayout(new GridLayout(0, 1, 5, 5));
          //set the color
          pane.setBackground(Color.GREEN);
          //make a font to use in components
          Font font1 = new Font("SansSerif", Font.BOLD, 16);
          /**New calendar object to display the date and time*/
          GregorianCalendar calendar = new GregorianCalendar();
          DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US);
          /**currentLocale = localeCode[comboSelectLocale.getSelectedIndex()];
          DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, currentLocale); //uses key for ResourceBundle*/
          TimeZone timeZone = TimeZone.getTimeZone("CST");
          //TimeZone timeZone = TimeZone.getTimeZone(localeTimeZone); //uses key for resourceBundle
          formatter.setTimeZone(timeZone);
          //***create UI objects***
          /**NEW OBJECTS FOR prjInternational:
           * a drop-down combobox, a label, and a txt field
          txtDateTime = new JTextField(formatter.format(calendar.getTime()));
          //txtDateTime = formatter.format(calendar.getTime());
          lblChoose = new JLabel("Please choose your language.");
          lblChoose.setFont(font1);
          lblChoose.setBackground(new Color(0, 212, 255)); //aqua blue
          comboSelectLocale = new JComboBox(localeList);
          comboSelectLocale.setFont(font1);
          comboSelectLocale.setBackground(new Color(0, 212, 255)); //aqua blue
          //comboSelectLocale.setSelectedIndex(0);
          //add a listener to the combo box to get the selected item
          /**default values for variables so I can debug--at the moment
           * I can't get the resouceBundle to work--it can't locate the
           * file.  So I will hard code these in for now.
          /*titleTxt="Food Weight Converter";
          enterTxt="Please enter the Weight you wish to convert.";
          btnTxt="Convert this weight!";
          gramTxt="grams";
          ozTxt="oz";
          resultDisplayTxt="Result will display here.";*/
          comboSelectLocale.addItemListener(new ItemListener()
               public void itemStateChanged(ItemEvent e)
                    res = setCurrentLocale(comboSelectLocale.getSelectedIndex());
                    System.out.println(res.getString("enterTxt"));
                    updateItems(res);
                  //set variables from Resource Bundle
                  /* titleTxt = res.getString("titleTxt");
                   System.out.println(res.getString("enterTxt")); //debug
                   enterTxt = res.getString("enterTxt");
                   btnTxt = res.getString("enterTxt");
                   gramTxt = res.getString("gramTxt");
                   ozTxt = res.getString("ozTxt");
                   resultDisplayTxt = res.getString("resultDisplayTxt");*/
          //2 radio buttons
          //optGram = new JRadioButton("grams", true);
          optGram = new JRadioButton(gramTxt, true);
          //optOz = new JRadioButton("oz.");
          optOz = new JRadioButton(ozTxt);
          optGram.setBackground(Color.GREEN);
          optGram.setFont(font1);
          optOz.setBackground(Color.GREEN);
          optOz.setFont(font1);
          //button group so only one can be chosen
          ButtonGroup weightUnit = new ButtonGroup();
          weightUnit.add(optGram);
          weightUnit.add(optOz);
          //label and text field for weight
          //JLabel lblWeightEnter = new JLabel("Please enter the weight you wish to convert:");
          JLabel lblWeightEnter = new JLabel(enterTxt);
          lblWeightEnter.setFont(font1);
          txtWeightEnter = new JTextField("20.05", 6);
          txtWeightEnter.setBackground(new Color(205, 255, 0)); //lime green
          txtWeightEnter.setFont(font1);
          //button to make conversion
          //cmdConvert = new JButton("Convert this weight!");
          cmdConvert = new JButton(btnTxt);
          cmdConvert.setFont(font1);
          //textfield to display result
          //txtResult = new JTextField("Result will display here");
          txtResult = new JTextField(resultDisplayTxt);
          txtResult.setBackground(new Color(205, 255, 0)); //lime green
          txtResult.setFont(font1);
          //register the handler
          convertWeight = new CmdConvertWeight();
          cmdConvert.addActionListener(convertWeight);
          //add content to pane
          pane.add(txtDateTime);
          pane.add(lblChoose);
          pane.add(comboSelectLocale);
          pane.add(lblWeightEnter);
          pane.add(txtWeightEnter);
          pane.add(optGram);
          pane.add(optOz);
          pane.add(cmdConvert);
          pane.add(txtResult);
          //create window for object
          setTitle(titleTxt);
          setSize(400, 300);
          setVisible(true);
          setLocationRelativeTo(null);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
       }//end of constructor
       /**  ACTION LISTENER CLASS TO RESPOND TO USER'S INPUT (EVENTS) **/
       private class CmdConvertWeight implements ActionListener
          public void actionPerformed(ActionEvent e)
             //System.out.println("we made it to the Action Listener"); //debug
             //get info from fields
             double weight = Double.parseDouble(txtWeightEnter.getText());
             double weightConvert = 0;
             String weightConvertString;
             if (optGram.isSelected())//if user's weight is in grams, converting to oz
             weightConvert = weight/28.35;
             weightConvertString = Double.toString(weightConvert);
             txtResult.setText(txtWeightEnter.getText() + " grams is equal to " + weightConvertString + " oz.");
             }//end if gram select
             else if (optOz.isSelected())//if user's weight is in oz, converting to grams
             weightConvert = weight*28.35;
             weightConvertString = Double.toString(weightConvert);
             txtResult.setText(txtWeightEnter.getText() + " oz. is equal to " + weightConvertString + " grams.");
             }//end if oz select
         }//end actionPerformed
      }//end CmdConvertWeight
       /**setCurrentLocale method from combo box listener*/
       public ResourceBundle setCurrentLocale(int index)
            Locale currentLocale = localeCode[index];
            System.out.println(currentLocale); //debug
            System.out.println("MyResource_" + currentLocale); //debug
            ResourceBundle res = ResourceBundle.getBundle("MyResource_" + currentLocale);
            return res;
       }//end setCurrentLocale
       public void updateItems(ResourceBundle res)
            //convertWeight1.setTitle(res.getString(titleTxt));
            System.out.println(res.getString(btnTxt));//debug
            lblWeightEnter.setText(res.getString(enterTxt));
            optGram.setText(res.getString(gramTxt));
            optOz.setText(res.getString(ozTxt));
            cmdConvert.setText(res.getString(btnTxt));
            txtResult.setText(res.getString(resultDisplayTxt));
       }//end updateItems
    }//end of class PrjGUIResourceBundles(each in a different file)
    public class MyResource_fr_FR extends java.util.ListResourceBundle
         static final Object[][] contents =
              {"titleTxt", "Convertisseur de poids de nourriture"},
              {"enterTxt", "Veuillez \u00E9crire le poids que vous souhaitez convertir."},
              {"btnTxt", "Convertissez ce poids!"},
              {"gramTxt", "grammes"},
              {"ozTxt", "onces"},
              {"resultDisplayTxt", "Le r\u00E9sultat montrera ici."},
              {"localeTimeZone", "CET"},
              {"dateFormat", "Locale.FR"}
         public Object[][] getContents()
              return contents;
    public class MyResource_es_MX extends java.util.ListResourceBundle
         static final Object[][] contents =
              {"titleTxt", "Convertidor del peso del alimento"},
              {"enterTxt", "Incorpore por favor el peso que usted desea convertir."},
              {"btnTxt", "\u00F1convierta este peso!"},
              {"gramTxt", "gramos"},
              {"ozTxt", "onzas"},
              {"resultDisplayTxt", "El resultado exhibir\u00E1 aqu\u00ED."},
              {"localeTimeZone", "CST"},
              {"dateFormat", "Locale.MX"}     
         public Object[][] getContents()
              return contents;
    public class MyResource_en_US extends java.util.ListResourceBundle
         static final Object[][] contents =
              {"titleTxt", "Food Weight Converter"},
              {"enterTxt", "Please enter the weight you wish to convert."},
              {"btnTxt", "Convert this weight!"},
              {"gramTxt", "grams"},
              {"ozTxt", "oz"},
              {"resultDisplayTxt", "Result will display here."},
              {"localeTimeZone", "CST"},
              {"dateFormat", "Locale.US"}
         public Object[][] getContents()
              return contents;
    }Edited by: JessePhoenix on Nov 2, 2008 8:30 PM

    catman2u wrote:
    does anyone from Lenovo actually read this forum?
    From the Communiy Rules in the Welcome section....
     Objectives of Lenovo Discussion Forums
    These communities have been created to provide a high quality atmosphere in which users of Lenovo products and services may share experiences and expertise. While members from Lenovo may participate at intervals to engage in the discussions and offer advice and suggestions, this forum is not designed as a dedicated and staffed support channel. This is an informal and public forum, and Lenovo does not guarantee the accuracy of information and advice posted here -- see important Warranty information below.
    No amount of ranting is going to get you anything more than you will achieve with a clear exposition of your issue... so you might want to try doing that instead of ranting and assuming that everyone already knows what you know etc etc.
    Cheers,
    Bill
    I don't work for Lenovo

  • Help with JTree node handles icon

    Hi
    In my application i use Jtree to display the hirearchical data.But i don't want to the node handles icon to be displayed in the screen.The root node handle icon will be not be displayed if we set jtree.setShowsRootHandles(false) .Is there any way to diable the other node handles icons too?.Please help me in overcoming the problem.
    So, i will be handling the expand/collapse operations of the node with the help of mouse click event.
    Thanks in advance.
    Regards,
    Krish.

    Hi all,
    Any ideas to overcome this problem.?
    Thanks,
    Krish

  • Swing application with network event handling

    Hello, hope this is the right place for this post. I'm the design phase of a client application in java which talks to a remote server written in C via sockets. I have a design problem: I want my Swing app to have a GUI with buttons and all for normal activities, which activities report to the server, and I want the client to react to server calls anytime without interrupting normal GUi activities. Plus, all must work together, so I would prefer having a single thread for the app. (Think of an IRC client: the user uses the GUI for activities and sendim messages, and meanwhile the client listens for messages from the server and display them as they arrive). My question is: is this possible?
    I have something like (in pseudo-java):
    classMyApp extends JFrame {
      public MyApp() {
        // Manages and create the GUI
        NetHandler h = new NetHandler(this);
        h.connect();
        while(true) {
          h.pollNetEvents();
    class NetHandler {
      private BufferedReader iStream;
      private PrintWriter oStream;
      private MyApp app;
      public NetHandler(MyApp a) {
        app = a;
        Socket socket = createSocket(ip, port);
        iStream = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        oStream = new PrintWriter(socket.getOutputStream());
        handshakeWithServer(); // Login & Password
      public pollNetEvents() {
        try {
          String s;
          for (;;) {
            s = iStream.readLine();
            if (s.equals("") == false)
              break;
            else
              app.parseCommand(s);
        catch (IOException e) {
          app.sendMessage("Error in pollNetEvent: " + e);
    }Roughly, something like this. With this solution the GUI works, but I cannot get the message the server sends.
    I hope my message is clear enough. Can anybody help me with the design of my app? Thanks a lot.
    Fabio.

    You might consider posting this in the Swing forum. You might get a more complete response there, but here are my first thoughts.
    -- I think you will end up wanting to use multiple threads, but only one thread will update the UI. For more about threading in Swing, see this tutorial: http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
    and maybe also here: http://www.sourcebeat.com/TitleAction.do?id=10 (look at the sample chapter on Threads)
    -- For the polling code ...
    Of course, if you use the classes provided for client/server communication described below, you don't need to write your own polling code. You may still wish worry about threading so that your UI remains responsive and does not encounter major issues: http://java.sun.com/developer/JDCTechTips/2005/tt0419.html#1
    -- Updates to the UI from thread(s) that are not on the Event Dispatch Thread (the one that controls the UI) must be posted using the SwingUtilities methods, such as invokeLater
    Message was edited by:
    pthorson

  • First Mac-need help with an "event"

    Hi:
       After 3 days of busy activity with no freeze ups, I was feeling pretty confident.  However, late last night I ran into an "event" that eventually required me to reload Tiger.
       (1) I was working along and for some reason, clicking my mouse did not have any effect on any of the programs--either those running or attempting to start new ones.  
       (2) I was able to tab through those programs running and with a command-Q quit out of those running...still no effect on any mouse clicks....no problem moving the mouse and it would highlight top left corner buttons, but no effect if I attempted to minimize or exit.
       (3) I shut the computer off and restarted a number of times....came up to the same screen each time.    Held the off button both in shutting down and starting up and this time it would go to the log on screen where I was able to type in my password.  Would come up to the same screen as I left it.
       (4) Was able to use the remote control just fine to look at pictures, etc.
       (5) After some reading, did a PRAM reset....same story as above.
       (6) Finally reloaded a new copy of Tiger and was back in business.
    Questions:
      (1) Is this the typical freeze people are getting....with PCs, when it freezes, nothing moves and when you reboot, you have a fresh start?
      (2) Short of reloading Tiger, if this happens again, what remedy (other than sending my new iMac back!) would you suggest?
    Thanks for your help!

    Many thanks for the suggestion and the giving me some hope that this is not the dreaded freeze issue!
    I forgot to mention perhaps one important bit of information: There were two Finder "windows" that were present when my "event" occurred and each time I rebooted, these same two Finder windows reappeared and my mouse was unable to move them or close them or execute any command line operations.
    Not sure if this changes the story about it being a mouse software related error or not, but I found it strange that on hard reboots the machine came back with the same two windows of information.

  • Need help with Buttons/Events

    HI
    Here is what I am doing. I am creating an "operations"
    calendar for my workplace. So far I have been successful with
    creating the page, inserting links, tags, images etc.....
    But now I want to add an Event button - where once the button
    is clicked - it will launch a script on my UNIX server.
    Cant quite figure this one out
    Any help would be greatly appreciated

    Hey man, I 've done some correction, and it seems work, why don't you try the code to see if it is what you want.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class ComplexMenu11 extends Applet implements ActionListener {
    Button open, close;
    MenuFrame f;
    public void init() {
    open = new Button("Open");
    add(open);
    open.addActionListener(this);
    close = new Button("Close");
    add(close);
    close.addActionListener(this);
    f = new MenuFrame("A Complex menu");
    f.setSize(200, 200);
    f.show();
    public void actionPerformed(ActionEvent evt) {
    if(evt.getSource() == open) {
    if(f.isShowing())
    f.show();
    }else{
    if(!f.isShowing())
    f.hide();
    class MenuFrame extends Frame implements ActionListener{  //and implements here too
    Font font;
    Label l;
    int fontsize;
    //MessageDialog md;
    MenuBar mb = new MenuBar();
    Menu m1 = new Menu("Colours");
    MenuFrame(String name) {
    super(name);
    m1.add(new MenuItem("White"));
    m1.add(new MenuItem("Light grey"));
    m1.add(new MenuItem("Yellow"));
    Menu m2 = new Menu("Font");
    m2.add(new MenuItem("10"));
    m2.add(new MenuItem("12"));
    m2.add(new MenuItem("14"));
    m2.add(new MenuItem("16"));
    m2.add(new MenuItem("18"));
    m2.add(new MenuItem("Message"));
    mb.add(m1);
    mb.add(m2);
    setMenuBar(mb);
    m1.addActionListener(this); //Add listener here
    l = new Label("A frame demonstration", Label.CENTER);
    add("South", l);
    //md = new MessageDialog(this,"Name",true);
    public void actionPerformed(ActionEvent evt) {
    if(evt.getSource() instanceof MenuItem) {
    //fontsize = 18;
    String label = evt.getActionCommand();
    if(label.equals("White")) {
    //setBackground(Color.white);
    System.out.println("This is the white point");
    }

  • Need help with custom event from Main class to an unrelated class.

    Hey guys,
    I'm new to Flash and not great with OOP.  I've made it pretty far with google and lurking, but I've been pulling my hair out on this problem for a day and everything I try throws an error or simply doesn't hit the listener.
    I'm trying to get my Main class to send a custom event to an unrelated class called BigIcon.  The rest of the code works fine, it's just the addEventListener and dispatchEvent that isn't working.
    I've put in the relevant code in below.  Let me know if anything else is needed to troubleshoot.  Thank you!
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var iconLayer_mc:MovieClip = new MovieClip();
            public function Main()
                Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
                addChildAt(iconLayer_mc,0);
                placeIcons();
            function placeIcons():void
                var i:int;
                var j:int;
                for (i = 0; i < 4; i++)
                    for (j = 0; j < 5; j++)
                        //iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
                        var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i,j);
                        iconLayer_mc.addChild(placedIcon_mc);
            function fl_MouseClickHandler(event:MouseEvent):void
                dispatchEvent(new Event("twitchupEvent",true));
    BigIcon.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.utils.getDefinitionByName;
        public class BigIcon extends MovieClip
            private var iconImage_str:String;
            private var iconRow_int:int;
            private var iconColumn_int:int;
            public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
                iconImage_str = iconImage_arg;
                iconRow_int = iconRow_arg;
                iconColumn_int = iconColumn_arg;
                this.addEventListener(Event.ADDED_TO_STAGE, Setup);
            function Setup(e:Event)
                this.y = iconRow_int;
                this.x = iconColumn_int;
                var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
                var thisIcon_mc:MovieClip = new ClassReference;
                this.addChild(thisIcon_mc);
                addEventListener("twitchupEvent", twitchUp);
            function twitchUp(e:Event)
                this.y +=  10;

    Ned Murphy wrote:
    You should be getting an error for the Main.as class due to missing a line to import the Event class...
    import flash.events.Event;
    My apologies, I should attempt to compile my example code before I ask for help...
    Alright, this compiles, gives me no errors, shows my 'book' and 'flowers' icons perfectly when ran, and prints 'addEventListener' to the output window as expected.  I get no errors when I press the button, 'dispatchEvent' is output (good), but the 'twitchUp' function is never called and 'EventTriggered' is never output. 
    How do I get the 'twitchUp' event to trigger?
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.events.*;
        public class Main extends MovieClip
            var iconLayer_mc:MovieClip = new MovieClip();
            var iconString_array:Array = new Array(2);
            public function Main()
                Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
                addChildAt(iconLayer_mc,0);
                buildStringArray();
                placeIcons();
            function buildStringArray():void
                var i:int;
                var j:int;
                for (i = 0; i < 2; i++)
                    iconString_array[i] = new Array(3);
                    for (j = 0; j < 3; j++)
                        if (Math.random() > .5)
                            //'flowers' is the name of an illustrator object that has been converted to a MovieClip and is in the library
                            iconString_array[i][j] = "flowers";
                        else
                            //'book' is the name of an illustrator object that has been converted to a MovieClip and is in the library
                            iconString_array[i][j] = "book";
            function placeIcons():void
                var i:int;
                var j:int;
                for (i = 0; i < 2; i++)
                    for (j = 0; j < 3; j++)
                        //iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
                        var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i*50,j*50);
                        iconLayer_mc.addChild(placedIcon_mc);
            function fl_MouseClickHandler(event:MouseEvent):void
                dispatchEvent(new Event("twitchupEvent",true));
                trace("dispatchEvent");
    BigIcon.as
    package
        import flash.display.MovieClip;
        import flash.events.*;
        import flash.utils.getDefinitionByName;
        public class BigIcon extends MovieClip
            private var iconImage_str:String;
            private var iconRow_int:int;
            private var iconColumn_int:int;
            public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
                iconImage_str = iconImage_arg;
                iconRow_int = iconRow_arg;
                iconColumn_int = iconColumn_arg;
                this.addEventListener(Event.ADDED_TO_STAGE, Setup);
            function Setup(e:Event)
                this.y = iconRow_int;
                this.x = iconColumn_int;
                var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
                var thisIcon_mc:MovieClip = new ClassReference;
                this.addChild(thisIcon_mc);
                addEventListener("twitchupEvent", twitchUp);
                trace("addEventListener");
            function twitchUp(e:Event)
                this.y +=  10;
                trace("EventTriggered");
    Output:
    [SWF] Untitled-1.swf - 40457 bytes after decompression
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    dispatchEvent
    [UnloadSWF] Untitled-1.swf
    Test Movie terminated.

  • Help with the event log in the type B hub

    I have  probs with broadband slowing down and also with link going down a number of times again (it recovers quickly)
    I just wanted to confirm that the message in trhe event log in the type B hub:-
    (134558.700000) RTNL: Received ERROR reply 'No such process' for message type 0x19
    was the link dropping.
    Can anybody confirm this and does anyone know if/where the messages are documented?
    Thanks in advance
    Banz

    does nobody have any comments on this
    Mods - please help
    banz
    ps this is my last bump - I will give up after this

  • Help with NSButton event

    Hi,
    I have a problem: I want to place a NSButton with type of "Recessed Button" on NSView and part of button should be on view and another part should be outside of this view
    That's ok, but when cursor of mouse move inside button and outside view, button receive event about this.
    What need to do for this event do not send to button when cursor move outside my view ?
    Thanks

    I think that if replace options in NSTrackingArea for NSButton it will be help me
    In Debugger I saw that default options is 4225 - I think that it's NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways|NSTrackingAssumeInside
    I want replace it to NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways|NSTrackingInVisibleRect
    But if I do it in awakeFromNib function and add breakpoint in drawRect: -- it have first value. Somewhere value overwrite before drawRect:
    Code:
    //MyButton.mm
    - (void)awakeFromNib
    NSArray *a = [self trackingAreas];
    NSTrackingArea * t = [[NSTrackingArea alloc] initWithRect:(NSRect){0, 0, 100, 50}
    options:NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways|NSTrackingInVisi bleRect
    owner:self
    userInfo:nil];
    [self removeTrackingArea:[a objectAtIndex:0]];
    [self addTrackingArea:t];
    [t release];
    - (void)drawRect:(NSRect)aRect
    NSArray *a = [self trackingAreas];
    NSTrackingArea *t1 = [a objectAtIndex:0]; //always first value !!!
    [super drawRect: aRect];
    Any idea how to do that ?
    Message was edited by: pavelmagur

  • Help with key event

    hi everyone i need some help. i have to write an java application thatcreates a panel with three labels and three key events to call upon different methods. i try to creat a JFrame but have problems. anyone can help?
    Thanks

    public class MyClass extends JFrame{
    public MyClass(){
    getContentPane().add( new Label("One") );
    getContentPane().add( new Label("Two") );
    getContentPane().add( new Label("Three") );
    setSize(400,400);
    setVisible(true);
    public static void main(String[] args){
    MyClass myclass = new MyClass();
    public static void main is the starting point of a program.
    When the frame is created using
    MyClass myclass = new MyClass();
    The control goes to the constructor where you can add three labels.
    You can add three methods to MyClass and implement KeyListener in MyClass to build upon it.

  • SystemManagerHandler bug with otherSystemManager event handling?

    I've run across an issue with PopUpManager & Alerts generating stack overflow errors.
    When I have multiple windows in AIR open with Alerts active, and I click on any window with out an alert, I get the stack overflow error.
    (Note: You have to open the multiple windows first .. then trigger the alerts. If you open a window 1 at a time, and trigger the alerts .. you get no stack overflow)
    Anyways .. I traced this down inside of systemManagerHandler to the function windowedManagerHandler
    In that function is a piece of code for handling events triggered from other system managers:
    private function systemManagerHandler(event:Event):void
            if (event["name"] == "sameSandbox")
                event["value"] = currentSandboxEvent == event["value"];
               return;
    Notice in this code the last == ... that seems to be a coding error. If i change the line to  event["value"] = currentSandboxEvent = event["value"]; my stack overflow errors go away.
    Can anyone else confirm that this is indeed a coding error in systemManagerHandler ?

    Hi Luk,
    You don't mention which version or patch level of SBO your client is using. Does this happen for you on different patches?
    I did a quick test on one of my test systems (SBO 2007A SP1 Patch 9 HF1) and I only get one resize event firing. It's the same whether I run with no addons or with an addon that I wrote that adds controls to the sales order form and which moves those items when the form is resized.
    Kind Regards,
    Owen

  • Help with Comboboxes inside a repeater

    Hi, I have a problem that I really need some help, if anyone knows how to do it.
    I have to make in flex a dynamic form that has X questions and each question can be answered 3 times by sellecting Y options in a combobox. As you can Imagine the number of questions and answers can change.
    Something like this:
    QUESTION                          FIRST ANSWER   2nd ANSWER      3rd ANSWER
    1- Which option do you like?  Combobox: A      Combobox: C        CB: A
    2- Second Question?             Combobox: B      Combobox: C        CB: D
    3- Third Question?                 Combobox: A      Combobox: Blank  CB: B
    (CB: means Combobox - I just made it shorter so it could fit the window)
    I managed to correctly using a repeater show all the questions and each combobox has all the right options inside. All I want now is to get the data from those comboboxes.
    This is a Simplified code (I removed all the non-essencial stuff) so you can get an idea:
    <mx:Repeater id="rp">
    <mx:VBox label="{rp.currentItem.nome}"
    width="100%">
    <mx:Repeater id="qt"
    dataProvider="{rp.currentItem.tbdavaliacao_pergunta}">
    <mx:HBox width="100%"
    verticalAlign="middle"
    horizontalAlign="center">
    <!-- This is the question text -->
    <mx:Text text="{String(qt.currentItem.nome)}"
    textAlign="center"/>
    <!-- Next, are the 3 comboboxes that are repeated X times -->
                                            <mx:ComboBox dataProvider="{grau}"
                                                           id="auto"
                                                           textAlign="center">
                                             </mx:ComboBox>
                                            <mx:ComboBox dataProvider="{grau}"
                                                           id="superior"
                                                           textAlign="center">
                                            </mx:ComboBox>
                                            <mx:ComboBox dataProvider="{grau}"
                                                           id="resultado"
                                                           textAlign="center">
                                            </mx:ComboBox>
    </mx:HBox>
    </mx:Repeater>
    </mx:VBox>
    </mx:Repeater>
    Anyone has an idea of how can I get all the answers from all my dynamic comboboxes?
    The perfect AND ideal solution would be having X Dynamic objects with the question id + the combobox id storing the answer sellected.
    So I would know that the question 32 has the answers A, B and A for an example.
    qt.currentitem.id + combobox.id = selectedLabel
    (question ID) + (combobox id) = (selectedLabel)
    32auto = 'A'
    32superior = 'B'
    32resultado = 'A'
    Or just one arraycollection with all the answers...
    At this point, I would accept any answer or idea or sollution...
    Thanks a lot!!

    I've looked at the HR schema to provide an example
    From the EMPLOYEES table I would like to return the EMPLOYEE_IDs of the employees with the highest SALARY per JOB_ID. When considering the employees that have the same JOB_ID, if any of the employees have a MANAGER_ID of x then no employee is returned for that group of employees with the same JOB_ID. x will be passed in as a parameter to my procedure.
    Example
    MANAGER_ID of 99 passed in
    All of the EMPLOYEE_IDs with the max SALARY per JOB_ID returned - no one has a manager with MANAGER_ID of 99
    MANAGER_ID of 101 passed in
    101 returned - Neena has the max salary of all the AD_VPs and neither of the AD_VPs has a MANAGER_ID of 101 (ok I know this isn't true about the salary!)
    102 returned - Alexander has the max salary of all IT_PROGs and none of them has MANAGER_ID of 101
    (108 not returned as Nancy has MANAGER_ID of 101)
    109 returned - Daniel has the max salary of all the FI_ACCOUNTs and none of them has MANAGER_ID of 101
    etc... for all JOB_IDs
    MANAGER_ID of 102 passed in
    101 returned - Neena has the max salary of all the AD_VPs and neither of the AD_VPs has a MANAGER_ID of 102 (ok I know this isn't true about the salary!)
    (no IT_PROGs returned as Alexander has MANAGER_ID of 102)
    108 returned - Nancy has max SALARY and not a MANAGER_ID of 102
    109 returned - Daniel has the max salary of all the FI_ACCOUNTs and none of them has MANAGER_ID of 102
    etc... for all JOB_IDs
    MANAGER_ID of 103 passed in
    101 returned - Neena has the max salary of all the AD_VPs and neither of the AD_VPs has a MANAGER_ID of 103 (ok I know this isn't true about the salary!)
    (no IT_PROGs returned as several have MANAGER_ID of 103)
    108 returned - Nancy has max SALARY and not a MANAGER_ID of 103
    109 returned - Daniel has the max salary of all the FI_ACCOUNTs and none of them has MANAGER_ID of 103
    etc... for all JOB_IDs
    Hope this helps to explain things, and thanks to anyone that can help
    Rob

  • ComboBox event handling..

    if let say my comboBox got "A","B","C"...
    then i got name field and ID field.
    how can i make it where the comboBox "C" is choosen and it will record down?so that when i open that particular record back..it show "C"
    i can save the name and ID but do not know how to save the content of ComboBOx after choosen..please guide me..thank you

    Check out my RememberData class. I think it's along the lines of what you're looking for
    You are free to use and modify this code, but please do not change the package or take credit for it as your own code, except where you have made changes. Also note that I never actually implemented functionality to save to a zip archive.
    To be totally honest, I built this class and tested it a couple times, but I think it could well do with more testing. If you decide to use it, could you please email me feedback at some point at [email protected]? Thanks.
    =================================================
    RememberData.java
    * Created on Jul 3, 2005 by @author Tom Jacobs
    package tjacobs.io;
    import java.awt.Component;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipException;
    import java.util.zip.ZipFile;
    import java.util.zip.ZipInputStream;
    import java.util.zip.ZipOutputStream;
    import javax.swing.DefaultListModel;
    import javax.swing.JComboBox;
    import javax.swing.JList;
    import javax.swing.ListModel;
    import javax.swing.MutableComboBoxModel;
    import javax.swing.event.ListDataEvent;
    import javax.swing.event.ListDataListener;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import tjacobs.IOUtils;
    import tjacobs.zip.ZipUpdate;
    public class RememberData implements Runnable {
         private static HashMap<ListModel, JComboBox[]> mComboDependencies = new HashMap<ListModel, JComboBox[]>();
         private static HashMap<ListModel, CommonListDataListener> mModelListeners = new HashMap<ListModel, CommonListDataListener>();
         private static HashMap<ListModel, File> mFileMap = new HashMap<ListModel, File>();
         public static final String FOOTER = "\n\n\n";
         private boolean sWritingToFile = false;
         private static ArrayList<CommonListDataListener> sQueue;
         private boolean sRunning = true;
         private static RememberData sSingleton;
         private static boolean useZip = true;
         private RememberData() {
              super();
         public void run() {
              while (sRunning) {
                   if (sQueue.size() != 0) {
                        CommonListDataListener listener = sQueue.remove(0);
                        listener.saveChanges();
                   else {
                        synchronized (RememberData.class) {
                             try {
                                  RememberData.class.wait();
                             catch (InterruptedException ex) {}
         public void addDependencies(MutableComboBoxModel model, JComboBox[] combos) {
              if (sSingleton == null) {
                   //don't know how this could happen, but it's good just to be paranoid
                   throw new Error("RememberData: Singleton is null");
              mComboDependencies.put(model, combos);
              if (combos != null) {
                   ModelListener l = new ModelListener(model);
                   for (int i = 0; i < combos.length; i++) {
                        combos.addActionListener(l);
         private static class ModelListener implements ActionListener {
              private MutableComboBoxModel mModel;
              public ModelListener(MutableComboBoxModel model) {
                   mModel = model;
              public void actionPerformed(ActionEvent ae) {
                   //disable Listener
                   CommonListDataListener l = mModelListeners.get(mModel);
                   if (l == null) {
                        throw new RuntimeException("model must have listener");
                   JComboBox[] combos = mComboDependencies.get(mModel);
                   File f = mFileMap.get(mModel);
                   mModel.removeListDataListener(l);
                   loadData(mModel, f, combos);
                   mModel.addListDataListener(l);
                   //enable Listener
         public static void RememberData(MutableComboBoxModel model, File f) {
              RememberData(model, f, null);
         public static void RememberData(MutableComboBoxModel model, File base, JComboBox[] dependencies) {
              mFileMap.put(model, base);
              loadData(model, base, dependencies);
              CommonListDataListener l = new CommonListDataListener(model);
              model.addListDataListener(l);
              mModelListeners.put(model, l);
              if (sSingleton == null) {
                   sSingleton = new RememberData();
              sSingleton.addDependencies(model, dependencies);
         private static File getRelativeFile(File f, JComboBox[] dependencies) {
              if (dependencies != null) {
                   String path = f.getAbsolutePath();
                   int idx = path.lastIndexOf(".");
                   String ending = idx == -1 ? "" : path.substring(idx + 1);
                   path = idx == -1 ? path : path.substring(0, idx);
                   StringBuffer sb = new StringBuffer(path);
                   for (int i = 0; i < dependencies.length; i++) {
                        sb.append("-" + dependencies[i].getSelectedItem().toString());
                   f = new File(sb.toString() + ending);
              return f;
         private static void loadData(MutableComboBoxModel model, File f, JComboBox[] dependencies) {
              //create file name
              if (!useZip) {
                   f = getRelativeFile(f, dependencies);
              //test if exists
              if (f.exists()) {
                   try {
                        String s;
                        if (!useZip) {
                             s = IOUtils.loadTextFile(f);
                        else {
                             ZipFile zip = new ZipFile(f);
                             ZipEntry entry = zip.getEntry(getRelativeFile(f, dependencies).toString());
                             s = IOUtils.loadAllString(zip.getInputStream(entry));
                        int size = model.getSize();
                        for (int i = 0; i < size; i++) {
                             model.removeElementAt(0);
                        LineNumberReader lnr = new LineNumberReader(new StringReader(s));
                        lnr.readLine();
                        String line;
                        while ((line = lnr.readLine()) != null) {
                             model.addElement(line);
                   catch (IOException iox) {
                        iox.printStackTrace();
         private static String getHeader(Component c) {
              String name = c.getName();
              return c.getClass().getName() + " " + (name == null ? "Unnamed" : name) + "\n";
         public synchronized static void addToQueue(CommonListDataListener l) {
              if (sQueue == null) {
                   sQueue = new ArrayList<CommonListDataListener>();
              sQueue.remove(l);
              sQueue.add(l);
              if (sSingleton == null) {
                   sSingleton = new RememberData();
                   Thread t = new Thread(sSingleton, "Remember Data Thread");
                   t.setPriority(Thread.MIN_PRIORITY);
                   t.start();
              } else {
                   RememberData.class.notify();
         private static class CommonListDataListener implements ListDataListener {
              private DefaultListModel mModel;
              private MutableComboBoxModel mComboModel;
              private ListDataEvent ev;
              public CommonListDataListener(DefaultListModel model) {
                   mModel = model;
              public CommonListDataListener(MutableComboBoxModel model) {
                   mComboModel = model;
              public void contentsChanged(ListDataEvent ev) {
                   this.ev = ev;
                   addToQueue(this);
              public void intervalAdded(ListDataEvent ev) {
                   this.ev = ev;
                   addToQueue(this);
              public void intervalRemoved(ListDataEvent ev) {
                   this.ev = ev;
                   addToQueue(this);
              void saveChanges() {
                   File file = mFileMap.get(mModel);
                   JComboBox[] dependencies = mComboDependencies.get(mModel);
                   PrintWriter pw = null;
                   try {
                        if (!useZip) {
                             file = getRelativeFile(file, dependencies);
                             pw = new PrintWriter(new FileWriter(file));
                             String contents = null;
                             contents = getSaveString();
                             pw.print(contents);
                             pw.close();
                        else {
                             ZipUpdate.update(file.getPath(), getRelativeFile(file, dependencies).toString());
                   catch (IOException iox) {
                        iox.printStackTrace();
              public boolean equals (Object o) {
                   if (o instanceof CommonListDataListener) {
                        CommonListDataListener lis = (CommonListDataListener) o;
                        return lis.mModel == mModel;
                   return false;
              private String getSaveString() {
                   StringBuilder sb = new StringBuilder();
                   if (mModel != null) {
                        int size = mModel.getSize();
                        for (int i = 0; i < size; i++) {
                             if (i != 0) {
                                  sb.append('\n');
                             sb.append(mModel.getElementAt(i).toString());
                        return sb.toString();
                   //else
                   int size = mComboModel.getSize();
                   for (int i = 0; i < size; i++) {
                        if (i != 0) {
                             sb.append('\n');
                        sb.append(mComboModel.getElementAt(i).toString());
                   return sb.toString();

Maybe you are looking for

  • How do i delete a photo album sent from my pc from my iphone 5c

    this website is useless, talk about being led a merry dance by apple! All I want to know is how the **** do i delete a photo album (sent from my pc) from my iphone 5c....how hard can it be to find out??????

  • Printing causes macpro to crash/restart

    printing causes macpro to crash/restart

  • Skype - no video

    Hello al, I am new to the iPhone 4having got mine a week ago. I have loaded Skype and whilst I can make Skype calls there is no video in or out. Can anyone tell me how to resolve this. So far I have tried only at home on my own Wi Fi network albeit w

  • Play movies in QT Player, NOT in the browser!

    How do I get the QT-movies to play in QT Player instead of the browser? Can I specify this in the HTML-code? My webhotel is wyning about high bandwith usage. Is there any way to avoid high bandwith usage? I have three QT-movies at 3MB each. What abou

  • Slow Finder

    I just upgraded to Snow Leopard and everything is working fine, except that every time I open a window in the finder it takes roughly 5 seconds for it to open the window. My applications are running smoothly, and the internet is still moving at a nor