Question on Menu listener de selection

Hi,
I got an exception Exception in thread "AWT-EventQueue-0" while running the below program, please explain why this exception is coming.
Select the count menu and then deselect it an exception is occuring how to solve this, and explain what is the reason for the exception raising.
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class allframes {
     JFrame frame=new JFrame("Hello World");
     JDesktopPane pane;
public static void main(String[] args) {
     new allframes();
public allframes(){
     pane=new JDesktopPane();
     try{
          String str=JOptionPane.showInputDialog("Enter the Number of frames");
          int j=Integer.parseInt(str);
          for (int i = 1; i < j; i++) {
               JInternalFrame iframe=new JInternalFrame("Frame"+i,true,true,true,true);
               iframe.setBounds(i*20,i*20,150,100);
               pane.add(iframe);
               iframe.setVisible(true);
               iframe.setToolTipText("Frame"+i);
     catch(Exception e){
          JOptionPane.showMessageDialog(null,"Enter a valid no");
          System.exit(0);
     JMenuBar bar=new JMenuBar();
     JMenu menu=new JMenu("Count");
     JMenuItem item=new JMenuItem("Hello");
     JMenuItem item2=new JMenuItem("Raja");
     menu.addMenuListener(new hi());
     menu.add(item);
     menu.add(item2);
     bar.add(menu);
     frame.add(pane);
     frame.setJMenuBar(bar);
     frame.setSize(600,600);
     frame.setVisible(true);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
class hi implements MenuListener{
     public void menuSelected(MenuEvent e){
          int k=pane.getAllFrames().length;
          JOptionPane.showMessageDialog(null,"the no of frames are"+k);
//          int n = JOptionPane.showConfirmDialog(null,"sel  message");
//          System.out.println("sel " + n);
     public void menuDeselected(MenuEvent e){
          JOptionPane.showMessageDialog(pane,"Menu is deselected");
          System.out.println("desel");
//          int n = JOptionPane.showConfirmDialog(null,"de sel  message");
//          System.out.println("sel " + n);
     public void menuCanceled(MenuEvent e){
           JOptionPane.showMessageDialog(null,"Menu is canceled");
//          System.out.println("sel " + n);
}Edited by: RajivGuna on May 18, 2011 12:04 PM

It doesn't like the JOptionPane. When the option pane closes I think it tries to set focus back on the popup menu. However, the component is no longer visible. Get rid of the option pane.
Or you can wrap the code in an invokeLater:
SwingUtilities.invokeLater(new Runnable()
     public void run()
          JOptionPane.showMessageDialog(pane ,"Menu is deselected");
});

Similar Messages

  • I'm having problems (1)selecting onscreen text, (2) having problems resizing menu boxes and selecting menues with the cursor. I'm not able to select menus and move them. I'm not sure how to correct this.

    I'm having problems (1) selecting onscreen text, (2) resizing menu boxes and selecting menues with the cursor. I'm not able to select menus and move them. I'm not sure how to correct this.

    1) This is because of software version 1.1. See this
    thread for some options as to how to go back to 1.0,
    which will correct the problem...
    http://discussions.apple.com/thread.jspa?threadID=3754
    59&tstart=0
    2) This tends to happen after videos. Give the iPod a
    minute or two to readjust. It should now be more
    accurate.
    3) This?
    iPod shows a folder icon with exclamation
    point
    4) Restore the iPod
    5) Try these...
    iPod Only Shows An Apple Logo and Will Not Start
    Up
    iPod Only Shows An Apple Logo
    I think 3,4, and 5 are related. Try the options I
    posted for each one.
    btabz
    I just noticed that one of the restore methods you posted was to put it into Disk Mode First rather than just use the resstore straight off, I Have tried that and seems to have solved the problem, If it has thank you. previously I have only tried just restoring it skipping this extra step. Hope my iPod stays healthy, if it doesnt its a warrenty job me thinks any way thanks again

  • Using a menu ring to select DAQ device channel and indicator

    Hi,
    New user here. I am using the DAQ assistant with multiple analog inputs. I would like the front panel to have a menu ring where the user can select which channels are to be active. Also, this corresponds to a single graphical indicator. 
    Currently I have a VI that displays all channels each with its own indicator. I want to simplify the front panel so that a user can simply use a menu ring to select and focus on what he/she is interested in. Is it possible to use the Select Signals Express VI to implement this?
    Thank you!

    Drop the DAQ Assistant or convert it to regular DAQmx functions. The physical channel control does all that. Just look at the shipping examples.

  • How to create Drop down menu in the selection screen

    Hi all,
    How to create Drop down menu in the selection screen.
    Fast answer will be highly rewarded
    Regards
    Bikas

    hi ,
    TYPE-POOLS : vrm.
    TABLES:vbak,vbap.
    DATA : v(80) TYPE c.
    DATA: wa_vbak TYPE vbak,
          it_vbak TYPE vbak OCCURS 0 WITH HEADER LINE,
          wa_vbap TYPE vbap,
          it_vbap TYPE vbap OCCURS 0 WITH HEADER LINE.
      DATA: l_name TYPE vrm_id,
            li_list TYPE vrm_values ,
            v_count  TYPE i,
            l_value LIKE LINE OF li_list.
    PARAMETERS: p_test(20) AS LISTBOX VISIBLE LENGTH 60 MODIF ID DAT.
    INITIALIZATION.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM get_data.
      LOOP AT it_vbak.
        l_value-key =  it_vbak-vbeln .
        l_value-text = it_vbak-vbeln .
        APPEND l_value TO li_list.
      ENDLOOP.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = 'P_TEST'
          values          = li_list
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
    AT SELECTION-SCREEN ON P_TEST.
      clear : li_list , li_list[].
      SELECT vbeln
             matnr
             meins
             FROM vbap
             INTO CORRESPONDING FIELDS OF TABLE it_vbap
             WHERE vbeln = p_test.
    START-OF-SELECTION.
      SELECT vbeln
             matnr
             meins
             FROM vbap
             INTO CORRESPONDING FIELDS OF TABLE it_vbap
             WHERE vbeln = p_test.
      LOOP AT it_vbap.
        WRITE :/ it_vbap-vbeln, it_vbap-matnr,it_vbap-meins.
      ENDLOOP.
    *&      Form  get_Data
          text
    -->  p1        text
    <--  p2        text
    FORM get_data .
      SELECT  vbeln
              FROM vbak
              INTO  CORRESPONDING FIELDS OF TABLE it_vbak.
    ENDFORM.                    " get_Data
    regards,
    venkat.

  • Questions on the most efficient select query..

    What is the difference between the two select query & please explain y is the 2nd select query more efficient??
    DATA: MAX_MSGNR type t100-msgnr.
    MAX_MSGNR = '000'.
    SELECT * FROM T100 INTO T100_WA
      WHERE SPRSL = 'D' AND
            ARBGB = '00'.
      CHECK: T100_WA-MSGNR > MAX_MSGNR.
      MAX_MSGNR = T100_WA-MSGNR.
    ENDSELECT.
    DATA: MAX_MSGNR type t100-msgnr.
    SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr
      WHERE SPRSL = 'D' AND
            ARBGB = '00'.

    Hi,
    First never use Check statement in the Select.
    Next thing Select ... end select.
    Coming to ur question In case of first select it will fetch each record from the data base and compares that record value with the variable(MAX_MSGNR) and assigns the value to the variable. And this process will continue till the select reads all the records of the data base. Also these operations happens on the data base server. SO this query not only affect ur program but also others who is accessing the same data base.
    Second query is most efficient because of the aggregate function MAX. Here it will fetch all the records in single go and checks the max value for that column using
    optimising algorithm. So number of checks, assignments(single assignment) and fetches will be less compared to first select. This is the main reason. Hope this clarified ur doubt.
    Another thing is in first query we are selecting all the fields where as in second we are selecting only one field(required)
    Thanks,
    Vinod.
    Edited by: Vinod Kumar Vemuru on Mar 13, 2008 4:55 PM

  • HT201363 hi, I don't remember the answers for my security questions and I don't have "send an email to your rescue email address to reset your security questions and answers" when I select "Password and security" on my apple ID. What should I do?

    hi, I don't remember the answers for my security questions and I don't have "send an email to your rescue email address to reset your security questions and answers" when I select "Password and security" on my apple ID. What should I do?

    Hi Roy,
    Contact iTunes support:
    https://getsupport.apple.com/GetproductgroupList.action
    Select your country, complete the prompts.
    Or you can contact them by email:
    https://ssl.apple.com/emea/support/itunes/contact.html
    They usually will get back to you via your regular email within 24 hours.
    Cheers,
    GB

  • HT5312 I did all the steps, but my problem is that they are asking me some questions that I did not select when I created my Apple ID, so I clicked where it said reset security questions info... and then when I went to my email, they didn't sended me anyt

    I did all the steps, but my problem is that they are asking me some questions that I did not selected when I created my Apple ID, so I clicked where it said reset security quiestion info...... And then when I went and cheked my email, they did not send anything to me!
    This problem started 1 month ago!
    Ivana1728

    The email response is automated, and almost certainly is detected as "junk" or "spam". So, try again and check your spam folders for their reply.

  • How do I reset my security questions with out having to select a new apple id or a new password?

    How do I reset my secrit questions with out having to select a new apple id or a new password when I'm at the itunes store.

    You will be able to reset them via:
    appleid.apple.com
    If you do not know your password contact Apple's expresslane:
    expresslane.apple.com

  • How do I make one menu listen to the selection of another menu?

    Suppose here I've got 2 menus, Menu_A and Menu_B.
    The items of Menu_A are A1, A2, A3.... and the items of Menu_B should be refreshed upon the selection of each Menu_A item.
    For instance, if the user choose A1 in Menu_A, the items of Menu_B are updated as B1..... and if choosing A2 in Menu_A, Menu_B's items are updated as B2....
    So anyway to handle this?

    Such behavior is better suited to ChoiceBox than Menu... Users expect menus to be relatively stable.

  • LabVIEW 7.1: menu driven event structure question: How can I cause an event case to fire when either a boolean object or a menu item is selected without polling?

    I am using an event structure to eliminate the overhead associated with polling from the GUI. I have build cases associated with each front panel button, and would like to programmatically generate a menu for the vi, adding each selection from the menu to its associated case. However adding a "user event" to a case that is already associated with a front panel button does not seem to allow the selection of the associated user event. Do I have to register each option on the custom menu? Should I programmatically generate the menu and use the same array to register the choices? Are there any examples out there
    that would help me?
    Thanks!!!!
    Steve

    Hello:
    I visited the forum for the purpose of getting some ideas on user
    events architecture. Well, I have to finished standalone working
    modular VI codes one which works as a standalone local control and
    one  which works on a remote communications mode. Now these 
    codes in themselves has event driven capabilities my problem is I
    needed to create another topmost layer VI that will be capable of
    switching between these remote and local operating mode - which I was
    thinking also to be event driven. This maybe a poor idea but I tried
    anyway. Is the User Event loop can be nested? Meaning an event within
    an event thing?
    Regards,
    Berns B.
    Bernardino Jerez Buenaobra
    Senior Test and Systems Development Engineer
    Test and Systems Development Group
    Integrated Microelectronics Inc.- Philippines
    Telephone:+632772-4941-43
    Fax/Data: +632772-4944
    URL: http://www.imiphil.com/our_location.html
    email: [email protected]

  • Adding Menue Audio Track selection and soubtitles on/off

    Hi,
    with some help from replies to other questions I managed to get a working DVD/BR with cool 2.0 / 5.1 sound and subtitles.
    But for now I do have to select the audio track manually and also I do have to enable subtitles from the DVD/BR players menu.
    So I wanted to add a DVD/BR menu where you can choose the audio track which should be played and to switch on and of subtitles.
    I edited a nice PS PSD File with some buttons and they show up in Encore and I can do some "encore" editig like moving tham arrond or link to some other elements.
    My question: How do I get e.g. the Button "2.0 Stereo" to select the stereo track and the button "5.1 Surround" to select the 5.1 track. An other button should switch on/off the right subtitle
    Than I'd like to have a button which starts the video with the selected audio and if selected subtitle on.
    At the end of the movie I like to be back in the menu.
    I bet thats simple
    I thought to create different timelines and add the audio/video/subtitle, but that i have a lot of timelines in all sort of combinations; e.g. video ON, 5.1 sound ON, subtitle OFF ..... video ON, 2.0 sound ON, subtitle ON etc ....
    Thansk for any suggestion . and BIG thanks. Götz

    Thanks for your posting, but there is the higlight  Layer.
    I opend the menue in photoshot once more and enabled the layers.
    For me a button has the following different states:
    Normal, no highlight,just "plain" text. e.g. "English Subtitle". in that state, the Subtitle is NOT selected/enabled.
    Mouse Over, the highlight shows up, so you can see where you are with your mouse. e.g. "English Subtitle √"
    Mouse left click, the highlight "sticks" to the menue item and when moving the mouse avay it is still highlighted, e.g.  "English Subtitle √"
    So I'd liked to indicate which audio track is enabled/selected and if subtitles are off or on.
    I thought, the highlight button states are markend with (=1) & (=3) ....
    BTW. in encore menue edit mode, if I click the show selected/activated Subpicture Highlight, the right layer shows up (with my √-symbol)
    But in preview mode or on a burned dvd this did not work
    Regards . Götz

  • 1,000 menu items - each selection plays unique audio clip with same video

    Hi all,
    We're familiar with playing different audio tracks based on a menu selection - but we have a large number of clips for this project... so, here's our question:
    A viewer of our 30 minute dvd throws it in the player and selects the city they live. We want to have about 1,000 city names they can choose from.
    Based on their selection, (eg: Los Angeles) the DVD will play and then at 7 different points during playback, we need the name "Los Angeles" inserted/played along the main audio track.  If someone selects Portland, then Portland would be spoken in that spot instead, etc. 
    In terms of audio files, we have the one main audio that is the same for all menu selections, except for the spots where the city goes, it is just blank.
    We have recorded 1,000 unique audio clips of just the city name we want to include . (1 to 2 seconds long)
    What's the best way to insert the audio where we need it during playback - or is it even possible? (non-blu ray).  There is audio just before and after the point where the city name has to go, so the timing during playback is critical. (no pause or hiccup when inserting.)
    We thought about outputting 1,000 unique audio tracks (each 30 minutes long) that include the full audio along with the city, but we seem limited in the number of audio tracks on the Encore timeline (at least based on our limited authoring experience - is there a way to get more clips in encore beyond the # of audio tracks it allows?)
    In reading other posts, it seems we can set markers along the main audio track, dump all our city clips on a handful of audio tracks and have them pull in where needed but it seems it will cause the dvd to pause when doing this, and make for an interrupted viewing experience. Is that true?
    Any ideas/thoughts are greatly appreciated...
    kay

    Let's see if someone can tell us how this might be done, but I say the answer is "no."
    First, DVDs are made for playing on TVs as programs, not as interactive media. You pick one audio track, and that is all you get. To do what you want (the main audio track with one of a thousand names spoken also), you need a thousand audio tracks.
    Even if it were possible, I think the number of menu choices (max 36 buttons on a single 4:3 menu) and the max 1 gig of menu on a disk, and if not those, the max 99 vts per disk (and for Encore which uses 1 vts per timeline, a  huge task to figure out how to make all those clips into chapters on timelines) etc.

  • How to log when a menu option is selected in an IVR Script

    Our business would like to track how many customers select a specific option in the menu of a CCX script.  For example: Customer calls in to the IVR and selects option 2 for a password reset within the menu.  My question is how to configure this within the script?
    We are running UCCX 8.0.
    Any help would be appreciated, thank you.

    The other thing we sometimes will do is to actually create a queue with no agents in it.  Queue the call and then dequeue the call, and you will be able to run reports on that queue to see how many calls went into it.  It's a workaround, but is sometimes easier for customers in smaller environments especially.
    John Irey
    Tympani Inc.

  • How to make menu to auto close when a menu item is selected?

    hi ...my question is described above..
    to make things clearer i have written a mini code to demonstrate my problem
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    /* just a frame with a JMenuBar with a JMenu with two RadioButtons
    public class myFrame2 extends JFrame implements ActionListener{
         JMenuBar mb ;
         JMenu mi;
         JRadioButton rb1;
         JRadioButton rb2;
         public myFrame2(){
              super();
              mb = new JMenuBar();
              mi = new JMenu("New");
              rb1 = new JRadioButton("Button 1");
              rb1.addActionListener(this);
              rb1.setActionCommand("action1");
              rb2 = new JRadioButton("Button 2");
              rb2.addActionListener(this);
              rb2.setActionCommand("action2");
              mi.add(rb1);
              mi.add(rb2);
              mb.add(mi);
              setJMenuBar(mb);
              pack();
              setVisible(true);
         @Override
         public void actionPerformed(ActionEvent e) {
              // Do something......
         public static void main(String args[]){
              new myFrame2();
    }If you run this program you will see that when you select a RadioButton the menu doesn't hide ...
    How can i make it hide when a menu item (JradioButton) is selected?
    thanks in advance
    Edited by: Pitelk on Jun 10, 2008 7:42 AM

    On a menu use JRadioButtonMenuItem.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class JRadioButtonMenuItemExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            JMenuBar mb = new JMenuBar();
            JMenu menu = new JMenu("menu");
            mb.add(menu);
            ButtonGroup bg = new ButtonGroup();
            JRadioButtonMenuItem item1 = new JRadioButtonMenuItem("alpha");
            bg.add(item1);
            menu.add(item1);
            JRadioButtonMenuItem item2 = new JRadioButtonMenuItem("beta");
            bg.add(item2);
            menu.add(item2);
            JRadioButtonMenuItem item3 = new JRadioButtonMenuItem("gamma");
            bg.add(item3);
            menu.add(item3);
            JFrame f = new JFrame();
            f.setJMenuBar(mb);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(400, 300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Safari pull down menu click to select fails

    Safari on my Mac Pro running 10.8.3 has suddenly stopped allowing me to select items in pull down menus with a single click. It was working earlier today but after my lunch when I woke the Mac Pro from sleep I can select anything in a pull down menu with my trackpad.
    Allan

    Glad I have insisted, you are on the most buggy CP-release ever. Please, install ASAP the bug patch that was released in October 2012! In the list with fixed bugs,were at least 30 bugs that I reported myself.
    Some reading links: http://blog.lilybiri.com/why-i-like-shape-buttons-captivate-6
    http://blog.lilybiri.com/toggle-shape-buttons
    http://blog.lilybiri.com/want-a-button-on-question-slide-in-captivate
    I also did a webinar, with focus on shape buttons. You can watch it On Demand on the Adobe site, search for the title 'Lilybiri's favourite...'

Maybe you are looking for

  • How do I swap out hard drives without losing all of my playlists?

    I got a bigger hard drive to store all of my music, and can't do a mass switch. I could delete everything out of my itunes and then add all from the new, but then I would lose all of my playlists.

  • Creating the New Update groups in case of the Credit Management

    Hi Can any one help out in the following requirement:   Is it possible to Create a new update group in case of the Credit Management?SAP standard provides only three update groups viz., 000012, 000015 and 000018. We would like to have a customized gr

  • Smartform problem with FS [short dump]

    Hi Abapers, Am using <FS> in my smartform it is using as Work area. Bcoz my line item data Containing Amount and Quantity fields. so when am not using <FS> i.e., if am declaring WA like <struc> then its giving error message like Quantity does not exi

  • Retrieving SID (Session Id ) for a Oracle Forms Session

    Hi I am using financials after a break of couple of years and things have changed. I am trying to trace a form .So I set trace from the menu.Then I open the form Query , do other activities and close the form.Then I go to the Unix server and examine

  • Exporting .mov to .avi file: computer crashes

    I'm trying to export a .mov file to .avi. I get about 80% through this and my computer crashes. I'm guessing it's because my memory can't handle it (have got 512MB SDRAM only), but I might be wrong about this. The .mov file originally came in a zippe