MenuBar Menu Items Events?

Hi
I have just started playing with Flex 2 Builder and I have
built a simple
app to get my feet wet. I have a menubar at the top of my app
with three
menus each with three choices
MENU1
SUB1A
SUB1B
SUB1C
MENU2
SUB2A
SUB2B
SUB2C
MENU3
SUB3A
SUB3B
SUB3C
My problem is that there does not seem to be a way to access
the sub menu
items and assign events to each. When I put an onClick event
in the
<mx:MenuBar> it fires regardless of which submenu item
I choose.
Is there a way, or what is the best way, to create individual
events for
each submenu? Additionally, can I add additional elements to
my <menuitem>
tags such as <menuitem label="SUB3A" someValue="XYZ">
and then access
"someValue" from whatever event I get to fire when the sub
menu is clicked?
Thanks
Rich

Hi --
Thanks for this example. This should really help me out.
Rich
"ntsiii" <[email protected]> wrote in message
news:e8bnbt$2lk$[email protected]..
> When the event fires, the event object passed into the
handler can be used
> to
> access the item that created the menu option. You can
use information in
> the
> item to decide what action to take. Here is a simple
example:
>
> Tracy
>
> <?xml version="1.0"?>
> <!-- Simple example to demonstrate the MenuBar
control. -->
> <mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
> creationComplete="initCollections();" >
>
> <mx:Script>
> <![CDATA[
>
> import mx.events.MenuEvent;
> import mx.controls.Alert;
> import mx.collections.*;
>
> [Bindable]
> public var menuBarCollection:XMLListCollection;
>
> private var menubarXML:XML =
> <root>
> <menuitem label="Menu1">
> <menuitem label="MenuItem 1-A" data="1A"/>
> <menuitem label="MenuItem 1-B" data="1B"/>
> </menuitem>
> <menuitem label="Menu2">
> <menuitem label="MenuItem 2-A" type="check"
> data="2A"/>
> <menuitem type="separator" />
> <menuitem label="MenuItem 2-B" >
> <menuitem label="SubMenuItem 3-A" type="radio"
> groupName="one" data="3A"/>
> <menuitem label="SubMenuItem 3-B" type="radio"
> groupName="one" data="3B"/>
> </menuitem>
> </menuitem>
> </root>;
>
> // Event handler for the MenuBar control's change event.
> private function menuHandler(event:MenuEvent):void
> {
> Alert.show("Label: " + event.item.@label + "Data: " +
> event.item.@data, "Clicked menu item");
> }
>
> // Event handler to initialize the MenuBar control.
> private function initCollections():void
> {
> menuBarCollection = new
> XMLListCollection(menubarXML.children());
> }
> ]]>
> </mx:Script>
>
> <mx:Panel title="MenuBar Control Example"
height="75%" width="75%"
> paddingTop="10" paddingLeft="10">
>
> <mx:MenuBar labelField="@label"
change="menuHandler(event);"
> dataProvider="{menuBarCollection}" />
>
> </mx:Panel>
> </mx:Application>
>
>

Similar Messages

  • C# Menu Item event problems

    Hey All,
    Hopefully my post gets through this time. I am having an issue with my C# application not receiving the menu events from Business One. If I run the sample VB app on my machine it works fine, and my C# code has the same logic. I have seen posts on the forum before with people having this issue but I do not think anyone has posted the reason.
    Any ideas why this is happening specifically with C#? Any SAP people out there had this happen before?

    Yes I have an event filter enabled on my forms. When i turn that off the menu event fires. That is weird isn't it?
    How do i add the menuitem event to my filter? I do not see that type in the help files. Also is there a certain order the filters need to be applied if I add the menuitem event?
    Thanks for the help

  • Menu disappears when accessing menu items in Web Dynpro

    Hi friends,
    I have a peculiar problem. I created a webdynpro application in WD for ABAP which displays a menu of Employee self services(ESS). In the window on the leftside the menu is displayed. if you click on any of the service name, the corresponding service will be displayed on the right side of the window. If another service is clicked, the previous service session will be logged out and the new service will be started in a new session. This is working fine.
    But if the user clicks on two or more services alternately, for a random number of times, sometimes the menu disappears and the whole of the window is occupied by the service frame itself. Sometimes this happens for a second click itself and sometimes it doesn't happen at all. Some other times it happens after clicking the services for nearly 50 times.
    It is difficult to test even because we do not know after how many attempts the menu will disappear and whether it will disappear at all.
    Can anyone suggest a solution.
    Edited by: yogesh devaramapti on Jun 4, 2009 9:48 AM
    Edited by: yogesh devaramapti on Jun 4, 2009 9:51 AM

    Hi Sujesh,
        First create a menu. Add menu items and then bind the menu item events to view controller actions. Define an event parameter mapping if you need to determine the menu item that triggered the action, or use separate actions for the menu items.
    For api see the link below:
    https://media.sdn.sap.com/javadocs/NW04/SP9/webdynpro/index.html
    Hope this helps.
    Regards,
    Pooja.

  • What event is generated whn i click on JMenu and not menu item

    I have a menu that does not have any menu item.
    but the event handling of it does not work i am using action performed.
    Am in wrong in the approach?
         //Build the second menu.
    menu2 = new JMenu("Options");
    menu2.setMnemonic(KeyEvent.VK_O);
    menuBar.add(menu2);
              menu2.addActionListener(this);     

    Hi there,
    Are you sure you downloaded it from mozilla.org and not from another site? There are unfortunately counterfeit sites out there that are trying to offer Firefox downloads when in reality they are malicious.
    Go to www.mozilla.org and make sure you install Firefox from there and let us know if that makes things work for you.
    Thanks!
    - David

  • Changing Dimensions of menu items in menubar

    I wanted to make the menu items have an auto width instead of
    a fixed with. So I followed the direction in the Help file under
    "Change dimensions of menu items" to change the .css. The menu
    items now seem to stretch to fit the width of the text, but the
    secondary menus now display horizontally instead of vertically
    below the top menu item. This is only in Explorer 6 & 7. Works
    fine in Firefox.

    Hi Kayo,
    You'll want to checkout these samples:
    http://labs.adobe.com/technologies/spry/samples/menubar/AutoWidthHorizontalMenuBarSample.h tml
    http://labs.adobe.com/technologies/spry/samples/menubar/AutoWidthVerticalMenuBarSample.htm l
    to see what browser bugs you're up against. :-)
    --== Kin ==--

  • Multiple menu items != multiple event handlers?

    I'm developing a program whereby a user can rate how much they like certain images when displayed on screen. The bulk of the work is done, but my rating mechanism (first attempt at one) is currently a right-click pop-up menu with the values 1-10 in ten menu items - naff I know, but its early design stages ;)
    This brings obvious problems, and I don't want to have to code event handlers for each and every Menu item just to set the same parameter to a different value depending on which menu item the user clicked (i.e. I don't want to have to create an event for the first menu item that simply sets and int variable to 1, and do the same for #2 through 10). What I was wondering was, is there any simpler way of implementing this? I.e. can I use the same event for the whole popup menu and detect the value of the option clicked and set the value accordingly? This would also mean, should I need to extend the rating scale above ten, say perhaps to twenty, then there would be no further coding necessary (which is nice! Lol!).
    Can anyone offer any suggestions? I did search, but tbh didn't have a clue what to search for. Your advice is appreciated.

    Implement the ActionListner that allows the constructor to take an argument as to the rating of the menu item, and then set the required rating variable to this when called. For example
    class MyRatingSystem
        int rating = 0;
        public void createMenus()
            JMenu ratings = new JMenu("Ratings");
            for(int i = 0; i < 10; i++)
                JMenuItem rating = new JMenuItem("Vote: " + i);
                rating.addActionListener(new RatingListener(i));
                ratings.add(rating);
        class RatingListener imlpements ActionListener{
            final int rate;
            public RatingListener(int rate)
                this.rate = rate;
            public void actionPerformed(ActionEvent ae)
                rating = this.rate;
    }The above code is inefficient and is only there to serve the purpose of an example(look at the loop, although I would think the compiler could do some loop unrolling?)
    HTH

  • Can I programmatically trigger a menu item tag selected event?

    I am trying to trigger a menu item selected event using built-in vi's. I want my Handle Menu vi to handle the case where the user checks on a boolean control as well as slected the menu option. I don't want to use POSTMESSAGE with acceleration key combination. Are there any built-in vi's which can "post" such a message?

    I have a similar situation and understand why adding a message to the menu queue would be an elegant solution to the problem.
    I have lots of menu bar selections in my program, and I would like to set up a button bar like most applications now have. To do this using the "in parallel" way becomes a ratsnets of wires and would take up a lot of window space.
    I have attached a file that is a good example of how to solve this problem with Event Structures in LabVIEW 6.1. It doesn't take up much additional diagram space and it can be quickly and easily reconfigured.
    It would be nice if future versions of LabVIEW had a more integrated button bar.
    Matt
    Attachments:
    Menu_and_button_bars.vi ‏68 KB

  • Spry Menu Bar - Different Background Image Wanted for menu items

    Hi, I've looked everywhere for help with this and just haven't found any answers yet ...
    I want my Dreamweaver CS5.5 menu to look like this design I've done in PhotoShop ...
    It's a simple one level list with no sub-levels.
    Everything is good, except I can only set one background image for all the menu items at this level.
    I want the first, last, and all the middle, menu items to use different background images.
    I have no idea where or how to insert the code to set a different background image for each individual menu item ...
    I know I could use images set one on top another in a column with rollover image swop, but the spry menu opens the door for dynamic content so I'm keen to get it working.
    Manchester city council has a great example of this style of menu design working at - http://www.manchester.gov.uk/
    They've got funky indenting of the text as well.
    ~~~~~~
    This is the code for my menu list ...
      <div class="sidebar1">
        <ul id="MenuBar1" class="MenuBarVertical">
          <li><a href="#">Home</a></li>
          <li><a href="#">News</a></li>
          <li><a href="#">Groups</a></li>
          <li><a href="#">Events</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Contact</a></li>
             <li><a href="#">Help</a></li>
        </ul>
      </div>
    This is how I set the background image (but I can only define one image) ...
    I set the image background to "Menu-Nav-Bar-Pic-Top-v1-w170px-h32px.jpg" through ...
    CSS Styles
    SpryMenuBarVertical.css
    ul.MenuBarVertical a
    I then select the background category
    and browse to the image file.
    doing this changes my CSS code as follows ...
    ul.MenuBarVertical li
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        position: relative;
        text-align: left;
        cursor: pointer;
        width: 170px;
        margin-top: 4px;
        margin-bottom: 4px;
        background: url(/Images/Menu-Nav-Bar-Pic-Top-v1-w170px-h32px.jpg);
    ul.MenuBarVertical ul
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        position: absolute;
        z-index: 1020;
        cursor: default;
        width: 170px;
        left: -1000em;
        top: 0;
        margin-right: 0;
        margin-bottom: 0;
        margin-left: 95%;
        background: url(/Images/Menu-Nav-Bar-Pic-Top-v1-w170px-h32px.jpg);
    ul.MenuBarVertical a
        display: block;
        cursor: pointer;
        padding: 0.5em 0.75em;
        color: #0000;
        text-decoration: none;
        font: normal 12px Verdana, Geneva, sans-serif;
        background: #EEE url(/Images/Menu-Nav-Bar-Pic-Top-v1-w170px-h32px.jpg);
    ~~~~~~
    These are the three images I want to apply to the top middle and bottom menu items :
    Top menu item background image - "Menu-Nav-Bar-Pic-Top-v1-w170px-h32px.jpg"
    Middle menu items background image - "Menu-Nav-Bar-Pic-Mid-v1-w170px-h32px.jpg"
    Bottom menu item background image - "Menu-Nav-Bar-Pic-Bot-v1-w170px-h32px.jpg"
    ~~~~~~
    As I am unable to set the menu items individually, this is how the menu looks like on my website at the moment ...
    ~~~~~~
    So near yet so far ! I'm hapy with the verdana font, the image size and spacing, but the background images I just can't set them right.
    I'd really appreciate any help on this as I'm out of ideas.
    Thank you.

    The easiest way is to use pseudo elements.
    To style the first and last menu items ifferently to the rest, merely add :first-child and :last-child respectivly as follows
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css">
    <style>
    ul.MenuBarVertical li:first-child a {
        background-color: red;
        color: white;
    ul.MenuBarVertical li:last-child a {
        background-color: green;
        color: yellow;
    </style>
    </head>
    <body>
    <ul id="MenuBar1" class="MenuBarVertical">
      <li><a href="#">Item 1</a></li>
      <li><a href="#">Item 2</a></li>
      <li><a href="#">Item 3</a></li>
      <li><a href="#">Item 4</a></li>
      <li><a href="#">Item 5</a></li>
    </ul>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>
    In your case, in liue of the background colour, you would have an image.
    Gramps

  • Alt+mnemonic key is not working properly for Menu Items

    Assume there are two menus , File Menu with mnemonic Alt+F
    and Save Menu with mnemonic Alt+S. File Menu contains the
    menu items like PageSetup with Mnemonic S. Save menu has
    the menu item Properties with Mnemonic P.
    Pressing Alt+F opens the File Menu which has the menu item
    PageSetup.Pressing S activates the PageSetup menu item.
    Similarly Pressing Alt+S opens the Save Menu which has the
    menu item Properties. Pressing P activates the Properties
    menu item acion. But Pressing Alt+P also activates the
    Properties menu item action(it is not the desired behaviour)
    Pressing Alt+Mnemonic key has to open only the Menus.It
    should not consider the menu items.
    STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
    1.Press Alt+F
    2.File Menu is invoked
    3.Press S
    4. Invokes the menu item action
    5. Press Alt+S
    6. Save menu is invoked
    7. Press P
    8. Invokes the menu item action
    9. Press Alt+P
    10. Invokes the menu item action
    EXPECTED VERSUS ACTUAL BEHAVIOR :
    Pressing of Alt+Mnemonic key invokes the menu and also menu
    item actions. If the same mnemonic is present in the Menu
    it is giving the priority to Menu only.Pressing of Alt key
    alone does not hiding the pull down menu
    Expected Result;
    Pressing of Alt+Mnemonic key has to list out the pull
    down menu only.It should not consider the menu items with
    the same mnemonic. If Alt key alone is pressed the pull
    down menu has to hide.
    REPRODUCIBILITY :
    This bug can be reproduced always.
    ---------- BEGIN SOURCE ----------
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class JavaBug extends JFrame
    public JavaBug()
    // Create menu bar
    JMenuBar menuBar = new JMenuBar(); // Create menu bar
    setJMenuBar(menuBar); // Add menu bar to window
    // Create first option on menuBar
    JMenu m1 = new JMenu("File");
    m1.setMnemonic('F');
    JMenuItem m1o1 = new JMenuItem("PageSetup");
    m1o1.setMnemonic('S');
    m1o1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("File/PageSetup was selected");
    m1.add(m1o1);
    // Create second option on menuBar
    JMenu m2 = new JMenu("Save");
    m2.setMnemonic('S');
    JMenuItem m2o1 = new JMenuItem("Properties");
    m2o1.setMnemonic('P');
    m2o1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("Save/Properties was selected");
    m2.add(m2o1);
    menuBar.add(m1);
    menuBar.add(m2);
    this.setTitle("Mnemonic Bugs");
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    setSize(400,250);
    show();
    public static void main(String[] args)
    JavaBug bug = new JavaBug();
    Suggestions welcomed
    punniya

    I tried your code, but didn't get your "bug" using jdk 1.3 on windows 2000 (at my school).
    Kind regards,
    Levi

  • Stuck in a Rut trying to activate a Dialog from a menu item

    I am building an application using Netbeans. I am stuck on getting a dialog window to open when i select a menu item. I have tried numerous alternatives and still can not seem to get it to work. I am sure it is a simple one; except, I am starting to repeat myself on the changes. I have decided to ask for help.
    The menu item is "OpenProfileMenuItem" and the method is "OpenProfileMenuItemActionPerformed". The dialog is "ProfileForm". How do I make this work?
    package BBCUtillity;
    import org.jdesktop.application.Action;
    import org.jdesktop.application.ResourceMap;
    import org.jdesktop.application.SingleFrameApplication;
    import org.jdesktop.application.FrameView;
    import org.jdesktop.application.TaskMonitor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Timer;
    import javax.swing.Icon;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    public class BBCUtilityView extends FrameView {
    public BBCUtilityView(SingleFrameApplication app) {
      super(app);
      initComponents();
    @Action
    public void showAboutBox() {
      if (aboutBox == null) {
       JFrame mainFrame = BBCUtility.getApplication().getMainFrame();
       aboutBox = new BBCUtilityAboutBox(mainFrame);
       aboutBox.setLocationRelativeTo(mainFrame);
      BBCUtility.getApplication().show(aboutBox);
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {}// </editor-fold>
    private void OpenProfileMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
      ProfileForm iForm = new ProfileForm();
      // TODO add your handling code here:
    // Variables declaration - do not modify
    private javax.swing.JMenuItem ImportMainDataMenuItem;
    private javax.swing.JMenuItem MergeDataMenuItem;
    private javax.swing.JMenuItem NewProfileMenuItem;
    private javax.swing.JMenuItem OpenProfileMenuItem;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration                  
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
    package BBCUtillity;
    import org.jdesktop.application.Application;
    import org.jdesktop.application.SingleFrameApplication;
    public class BBCUtility extends SingleFrameApplication {
    private mrkTable MarkerTable;
    @Override protected void startup() {
      show(new BBCUtilityView(this));
        MarkerTable = new mrkTable();
        MarkerTable.loadMarkers();
    //   MarkerTable.dumpTable();
    //   MarkerTable.saveMarkers();
    @Override protected void configureWindow(java.awt.Window root) {
    public static BBCUtility getApplication() {
      return Application.getInstance(BBCUtility.class);
      public static void main(String[] args) {
      launch(BBCUtility.class, args);
    package BBCUtillity;
    public class ProfileForm extends javax.swing.JDialog {
    /** Creates new form ProfileForm */
    public ProfileForm(java.awt.Frame parent, boolean modal) {
      super(parent, modal);
      initComponents();
      @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {}// </editor-fold>                       
      private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {                                      
       // TODO add your handling code here:
    public void ProfileForm(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
       public void run() {
        ProfileForm dialog = new ProfileForm(new javax.swing.JFrame(), true);
        dialog.addWindowListener(new java.awt.event.WindowAdapter() {
         @Override public void windowClosing(java.awt.event.WindowEvent e) {
          System.exit(0);
        dialog.setVisible(true);
    // Variables declaration - do not modify                    
    private javax.swing.JComboBox ModalCombo;
    private javax.swing.JComboBox ProfileCombo;
    private javax.swing.JComboBox PropCombo;
    // End of variables declaration                  

    This question should go into the Swing forum.
    I find the declaration, but no instance of OpenProfileMenuItem in your code (Java naming conventions request that variables start with lowercase characters). To this instance a listener must be attached, which when fired opens your dialog.

  • Can't get menu items to be displayed

    Hello,
    The answer to my problem is probably quite simple but I can't see it and its driving me crazy, basically I can't get my menu items to be displayed like file, create and search. But what ever I add to the file menu items like open or save isn't displayed and I don't know why I think it may have to do with the action listeners but I'm not sure how or why or it could be because of where it is placed in the code, but again I'm not sure. Any help will be appreciated thanks!
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.GeneralPath;
    import java.awt.geom.*;
    import java.awt.image.*;
    class CharacterEditor2 extends JFrame implements ActionListener
      private Container pane;
      public JPanel sidebar = new JPanel();
    public JPanel library;
      public JPanel interface1 = new JPanel();
      private JPanel interface2 = new JPanel();
      public JPanel cards = new JPanel();
      public CardLayout layout = new CardLayout();
      public JButton headb = new JButton ("Head");
      public JButton bodyb = new JButton ("Body");
      private JButton legsb = new JButton ("Legs");
      private JButton handsb = new JButton ("Hands");
      private JButton freeHandb = new JButton ("Free Hand");
      private JButton eyesb = new JButton ("Eyes");
      private JButton mouthb = new JButton ("Mouth");
      private JButton earsb = new JButton ("Ears");
      private JButton noseb = new JButton ("Nose");
      private JButton hairb = new JButton ("Hair");
      public CharacterEditor2()
        addWindowListener(new WindowAdapter(){
          public void windowClosing(WindowEvent e){
            System.exit(0);}});
        pane = getContentPane();
        setTitle("JHH");
        library = new library();
        interface2.setBackground(Color.red);
        interface1.setBackground(Color.green);
        Panel p1 = new Panel();
        p1.setLayout(new GridLayout(2,0));
        sidebar.setLayout(new GridLayout(3,0));
        addButton(sidebar, headb);
        addButton(sidebar, bodyb);
        addButton(sidebar, legsb);
        addButton(sidebar, handsb);
        addButton(sidebar, freeHandb);
        addButton(sidebar, eyesb);
        addButton(sidebar, mouthb);
        addButton(sidebar, earsb);
        addButton(sidebar, noseb);
        addButton(sidebar, hairb);
        JMenuBar menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);
        JMenu fileMenu = new JMenu("File");
        menuBar.add(fileMenu);
        JMenuItem openMI = new JMenuItem("Open");
        openMI.addActionListener(this);
        fileMenu.add(openMI);
        JMenuItem saveMI = new JMenuItem("Save");
        saveMI.addActionListener(this);
        fileMenu.add(saveMI);
        JMenuItem closeMI = new JMenuItem("Close");
        closeMI.addActionListener(this);
        fileMenu.add(closeMI);
        fileMenu.addSeparator();
        JMenuItem exitMI = new JMenuItem("Exit");
        exitMI.addActionListener(this);
        fileMenu.add(exitMI);
        JMenu createMenu = new JMenu("Create");
        menuBar.add(createMenu);
        JMenuItem entryMI = new JMenuItem("Entry");
        entryMI.addActionListener(this);
        createMenu.add(entryMI);
        JMenu searchMenu = new JMenu("Search");
        menuBar.add(searchMenu);
        JMenuItem searchCharacterMI = new JMenuItem("Search by Character");
        searchCharacterMI.addActionListener(this);
        searchMenu.add(searchCharacterMI);
        JMenuItem searchBackgroundMI = new JMenuItem("Search by Background");
        searchBackgroundMI.addActionListener(this);
        searchMenu.add(searchBackgroundMI);
        JMenuItem searchMovieMI = new JMenuItem("Search by Movie.");
        searchMovieMI.addActionListener(this);
        searchMenu.add(searchMovieMI);
        p1.add(sidebar);
        p1.add(interface1);
        p1.add(interface2);
        p1.add(library);
       //add scroller to library
       JScrollPane scroller =
             new JScrollPane(library,    
                       JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                       JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         scroller.setPreferredSize(new Dimension(100,100));
         p1.add(scroller, library);
        pane.add(p1, BorderLayout.CENTER);
      private void addButton (Container c, JButton b)
        b.addActionListener(this);
        c.add(b);
      public void actionPerformed(java.awt.event.ActionEvent evt)
    ((CardLayout)library.getLayout()).show(library, evt.getActionCommand());
      public static void main(String[] args)
        CharacterEditor2 window = new CharacterEditor2();
        window.setTitle("Character Editor");
        window.setSize(900, 700);
        window.setVisible(true);
    }

    It's because you are mixing Swing components and AWT components. The menu items are actually displayed, but they are hidden behind the panel with all the buttons. Things will work fine if you change the following line:
    Panel p1 = new Panel();  // This is an AWT panel. Use this instead:
    JPanel p1 = new JPanel();Read more about it here:
    http://java.sun.com/products/jfc/tsc/articles/mixing/

  • Trouble selecting menu item using AppleScript

    Now that iWork Numbers 3.2 has added the ability to hide columns and rows via the menubar, I'm trying to make it work in an Applescript using system Events and the click menu item command, but no dice.  Any ideas?
    tell application id "com.apple.iWork.Numbers"
      activate
              tell table 1 of the active sheet of document 1
                        --select the range
                        set thisRangeName to "A:B"
                        set the selection range to range thisRangeName
                        --hide the cells
                        tell application "System Events"
                                  tell application process "Numbers"
                                       --this causes an error
                                      click menu item "Hide 2 Columns" of menu 1 of menu bar item "Table" of menu bar 1
                                       --this doesn't seem to do anything
                                       click menu item 18 of menu 1 of menu bar item "Table" of menu bar 1
                                  end tell
                        end tell
              end tell
    end tell

    I finally settled on this solution:
    tell application id "com.apple.iWork.Numbers"
         activate
         tell table 1 of the active sheet of document 1
              set thisRangeName to "A:B"
              set the selection range to range thisRangeName
         end tell
    end tell
    tell application "System Events" to tell process "Numbers"
         click menu bar item "Table" of menu bar 1
         keystroke "Hi"
         delay 0.5
         keystroke return
    end tell
    I would be curious to know if anyone has found a more elegant solution.

  • MenuBar mouse rollover event not firing

    Is MenuBar in SDK 4.1/4.5 a little flaky to anyone else?
    The rollover events fire as they should at first, but if you move the mouse fast enough, it seems to screw up eventually and at that point only the itemRollOut event is firing (no itemRollOver at all, even though the mouse clearly moved over a new menu item!) 
    Also sometimes I'm able to get the menu item's background-highlight effect to remain, if I move the mouse cursor away fast enough.  Is this a crummy or little used component, or what?  I'm using Halo only...

    Expected response on this, but I can add that it seems to happen mostly when a drop down menu has only one item listed.  The plan is to add more (obviously) but it's a little odd - I'm wondering if anyone can reproduce the same result with a MenuBar menu that only has one option.  Of course it works "at first", you have to play around with it a bit for the events to get out of sync, so it's tough...

  • Render menu item conditionaly in contextMenu

    Hi,
    I am having a tree with contextmenu facet. Also, I have a "Actions" drop-down with the similar set of menu items in my toolbar. I use the same jsff for both the menus like this:
    1) for tree context-sensitive menu:
    <f:facet name="contextMenu">
    <af:popup id="popContextMenu"
    rendered="#{userCanEdit}"
    contentDelivery="lazyUncached">
    <f:subview id="contextView">
    <jsp:include page="/oracle/communications/brm/pdc/ui/fragments/changeset/changeSetContextMenu.jsff"/>
    </f:subview>
    </af:popup>
    </f:facet>
    2) For Actions dropdown:
    <af:menuBar id="mb1" rendered="#{userCanEdit}">
    <f:subview id="csMenuBar"
    binding="#{viewScope.workspaceBean.csMenuBar}">
    <jsp:include page="/oracle/communications/brm/pdc/ui/fragments/changeset/changeSetContextMenu.jsff"/>
    </f:subview>
    </af:menuBar>
    My use case is, I need to show "Create" menu item if menu is accessed using Actions drop-down. However, if user right clicks the tree node "Create" should not be displayed in context-sensitive menu. Any idea how can I distinguish the source of event, what should be the EL in "render" property of commandmenuitem?
    Regards,
    Afroz

    Hi John,
    I tried following:
    <f:subview id="csMenuBar" binding="#{viewScope.workspaceBean.csMenuBar}">
        <jsp:include page="/oracle/communications/brm/pdc/ui/fragments/changeset/changeSetContextMenu.jsff" flush="true">
                         <jsp:param name="isAction" value="true"/>
         </jsp:include>
      </f:subview>And in the included page I try to read this parameter using El : *#{param.isAction}*
    However, #{param.isAction} always returns blank. Looks like the parameter is not passed to the included page. Is there any other way to read this parameter?
    Regards,
    Afroz

  • Implementing menu items and saving state in my app

    Hello
    I'm a new user to the forums, but have a little bit of java programming experience.
    currently i'm writing some business applications, one of which is a payroll system. The target audience is end-user bookkeepers so i am planning for a GUI front end.
    My first question relates to how programs save their state. for example, each month the bookkeeper will launch the program and add the next months payments, or he/she will open the program to fix a mistake. In general how do programs like word, excel (or anything) save and load files to work with? I was thinking about using XML. I thought i would load in an XML file containing all work so far, and then the user could save to it, which would add the new work.
    Question the second: A lot of gui java apps i use (like argo, symphony etc) have standard menus at the tops. Items like open, save, close, print etc. How are developers actually doing this? is there some premade classes i can just use in my programs as well that would be me this funtionality? This kindof relates to my first question about saving and opening. Further, it seems there are two GUI libraries to consider - either SWT or Swring. Eclipse plugins are written in SWT (from what i have heard). Can anybody recommend which API i should be using to create a GUI for my program?
    I think that's it for now. If anybody can provide me with advice i woudl be most grateful, as i'm at a bit of a standstill with my development.
    thanks.
    Edited by: minofifa on Oct 25, 2007 1:09 PM
    attempted to take topic off the watch list - sorry guys

    My first question relates to how programs save their state. for example, each month the bookkeeper
    will launch the program and add the next months payments, or he/she will open the program to fix a
    mistake. In general how do programs like word, excel (or anything) save and load files to work with? I
    was thinking about using XML. I thought i would load in an XML file containing all work so far, and then
    the user could save to it, which would add the new work. It sounds more like you are talking about saving the data instead of state--save in a database for mass and long term storage. Simple state info can be easily save in a database also or in a bean or text file.
    Question the second: A lot of gui java apps i use (like argo, symphony etc) have standard menus at
    the tops. Items like open, save, close, print etc. How are developers actually doing this? is there
    some premade classes i can just use in my programs as well that would be me this funtionality? This
    kindof relates to my first question about saving and opening. Further, it seems there are two GUI
    libraries to consider - either SWT or Swring. Eclipse plugins are written in SWT (from what i have
    heard). Can anybody recommend which API i should be using to create a GUI for my program?Maybe this is not what you are asking, but menu systems are implemented with Menu, MenuBar, MenuItem, etc objects in Java. The specifics of what happens when the individual menu items are selected are left up to the programmer.
    If you are looking for prebuilt menubars with code attached to perform common functions, then I do not know of any included in Java.

Maybe you are looking for

  • Printing System Date on Report Title

    How can I print the system date on the title of report generated by SQL*Plus? I remember it is possible to include SQL.PNO in the statement TTITLE to print the page number. Is there any variable like SQL.PNO which represent system date? Previously I'

  • Error message when using time capsule

    I recently installed a time capsule disk on my network. the initial implementation went well however when I went to my macbook pro the day after the initial backup was taking place, there was a message that the backup failed and couldn't be completed

  • Programati​cally create local variable in TestStand

    Can somebody please explain the process of creating a local variable programatically?  I have searched the forums but haven't found what I am looking for yet. I have an array of unknown size.  I use a foreach loop to step through the array and grab t

  • Mail won't work.  Spinning ball upon opening.

    Mail worked flawlessly until earlier I opened the app and I get a spinning ball that won't stop spinning. I let it go for at least 10 minutes until I forced quit and each time I open Mail this happens- with reboot or shutdown and restart. Anyone know

  • External hard drive library and USB flash drive

    My iPhoto library is located on my external hard drive (laptop HD too full). I'll bed traveling for Xmas, so copied about 1GB of pics (organized into an album) to the flash drive to take with me. Once disconnected from the external drive (where the l