Results 1 to 6 of 6

Thread: Confused with MenuElement interface

  1. #1
    Amol-Parcher Guest

    Confused with MenuElement interface

    Hello friend,

    I am beginner in the field of advanced java programming. Because of that I am quit getting troubled while understanding the 'MenuElement interface' of java language. I don't know anything about this interface of java programming. If you have good knowledge about the MenuElement interface of java, then please try to share it with me. I would greatly appreciate your any help over this issue.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Confused with MenuElement interface

    Hi,

    A MenuElement interface of java programming is basically implements JMenu class, JMenuBar class, JMenuItemclass and JPopupMenu class. There are many methods are available with this java interface and which are used for to access it's properties. Any component that can be placed into a menu should implement MenuElement interface. This interface is used by MenuSelection to handle selection and navigation in menu hierarchies.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Confused with MenuElement interface

    Hi friend,

    I recommend you to study carefully following MenuElement interface example:
    Code:
    import javax.swing.MenuElement;
    
    public class MenuElementDM extends JPanel {
    
      public JPopupMenu popup1;
      SliderMenuItem slider1;
    
      int theValue = 0;
    
      public MainClass() {
    
        popup1 = new JPopupMenu();
        slider1 = new SliderMenuItem();
        popup.add(slider1);
        popup.add(new JSeparator());
    
        JMenuItem labels1 = new JCheckBoxMenuItem("Slider Labels");
        labels.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            slider.setPaintLabels(!slider.getPaintLabels());
          }    };
        popup.add(labels1);
      }
      public static void main(String sgb[]) {
        JFrame frame002 = new JFrame("Menu Element Example");
        frame002.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame002.setContentPane(new MainClass());
        frame002.setSize(300, 300);
        frame002.setVisible(true);
      }
     }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Confused with MenuElement interface

    Please go through the following some methods of MenuElement interface:
    • processMouseEvent(MouseEvent evnt, MenuElement[] path1, MenuSelectionManager mngr)
    • getComponent()
    • processKeyEvent(KeyEvent evnt, MenuElmnt[] path, MenuSelectionManager mgr)
    • menuSelectionChanged(boolean bl)
    • getSubElements()

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Confused with MenuElement interface

    Hi,

    In following example of MenuElement interface, I have used it's methods:
    Code:
    import javax.swing.MenuElement;
    
    public class MenuElementSample
     {
      public static void main(final String arbgs[]) {
        JFrame gnj = new JFrame("MenuSample Example");
        gnj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JMenuBar menuBar1 = new JMenuBar();
    
          JMenu fileMenu1 = new JMenu("File");
        fileMenu.setMnemonic(KeyEvent.VK_F);
        menuBar1.add(fileMenu1);
     
        JToggleButtonMenuItem newMenuItem1 = new JToggleButtonMenuItem("New");
        fileMenu.add(newMenuItem1);
    
        gnj.setJMenuBar(menuBar1);
        gnj.setSize(300, 250);
        gnj.setVisible(true);
      }

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    Re: Confused with MenuElement interface

    A processMouseEvent() is one of the important method of 'MenuElement interface' of java. For this method you need to pass the mouseEvent event and mouseElement path as a parameter. You also need to pass value for 'MenuSelectionManager'. In which the event value is nothing but the source being the receiving component elements. While the value for paths is nothing but the path of receiving element.

Similar Threads

  1. Replies: 7
    Last Post: 22-10-2011, 10:35 PM
  2. Confused regarding RAM
    By Victorious in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 31-12-2010, 07:43 AM
  3. Confused between HTC Desire and HTC HD2
    By Gokul20 in forum Portable Devices
    Replies: 5
    Last Post: 12-03-2010, 03:44 PM
  4. Confused between override and new in C#
    By KANAN14 in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 06:47 AM
  5. Confused with Tft and Lcd. What is better?
    By Balamani in forum Monitor & Video Cards
    Replies: 3
    Last Post: 17-11-2009, 05:36 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,752,116,023.07676 seconds with 16 queries