Need help creating a menu bar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bucs44
    New Member
    • Jan 2007
    • 5

    #1

    Need help creating a menu bar

    I'm very green when it comes to writing code and I'm trying to create a menu bar and pull down menus. The menu bar contains three options: File, Edit and Help.

    The File menu contains four options: New, Open, Close and Send To. Among these four, the Send To entry itself is a menu with the following three options: Mail Recipient, Exchange Server and Floppy Disk

    The Edit menu has the following entries: Cut, Copy and Paste.

    The Help menu has two options: Contact Us and About Software

    Any help would be greatly appreciated.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Have you looked at eclipse's visual dialog creation tools? They will help you create your menus and other windows. As for getting all the code to make it do what you want, thats another story.

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      Here is their Graphic Modeling Framework. It is the plugin that you will need to use to allow eclipse to help you create model your GUIs.

      The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 360 open source projects, including runtimes, tools and frameworks.

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        Here's a picture of what you are looking for.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by Bucs44
          I'm very green when it comes to writing code and I'm trying to create a menu bar and pull down menus. The menu bar contains three options: File, Edit and Help.

          The File menu contains four options: New, Open, Close and Send To. Among these four, the Send To entry itself is a menu with the following three options: Mail Recipient, Exchange Server and Floppy Disk

          The Edit menu has the following entries: Cut, Copy and Paste.

          The Help menu has two options: Contact Us and About Software

          Any help would be greatly appreciated.
          I'd skip all those visual tools if I were you. The problem description almost
          naturally leads to the following code:
          Code:
          JMenuBar createMenuBar() {
             JMenuBar bar= new JMenuBar();
             bar.add(createFileMenu());
             bar.add(createEditMenu());
             bar.add(createHep[Menu());
          
             return bar;
          }
          JMenu createFileMenu() {
             JMenu menu= new JMenu("File");
          
             menu.add(createNewMenuItem());
             menu.add(createOpenMenuItem());
             menu.add(createCloseMenuItem());
             menu.add(createSendToMenu());
          
             return menu;
          }
          ...
          // etc.etc. etc.
          kind regards,

          Jos

          Comment

          • RedSon
            Recognized Expert Expert
            • Jan 2007
            • 4980

            #6
            Originally posted by JosAH
            I'd skip all those visual tools if I were you. The problem description almost
            naturally leads to the following code:
            Code:
            JMenuBar createMenuBar() {
               JMenuBar bar= new JMenuBar();
               bar.add(createFileMenu());
               bar.add(createEditMenu());
               bar.add(createHep[Menu());
            
               return bar;
            }
            JMenu createFileMenu() {
               JMenu menu= new JMenu("File");
            
               menu.add(createNewMenuItem());
               menu.add(createOpenMenuItem());
               menu.add(createCloseMenuItem());
               menu.add(createSendToMenu());
            
               return menu;
            }
            ...
            // etc.etc. etc.
            kind regards,

            Jos
            Fine, make it easy. See if I care :P

            The reason I was suggesting those visual tools is because it will be easier to make rich and complicated interfaces with them instead of creating them all programatically .

            Comment

            • Bucs44
              New Member
              • Jan 2007
              • 5

              #7
              Originally posted by JosAH
              I'd skip all those visual tools if I were you. The problem description almost
              naturally leads to the following code:
              Code:
              JMenuBar createMenuBar() {
                 JMenuBar bar= new JMenuBar();
                 bar.add(createFileMenu());
                 bar.add(createEditMenu());
                 bar.add(createHep[Menu());
              
                 return bar;
              }
              JMenu createFileMenu() {
                 JMenu menu= new JMenu("File");
              
                 menu.add(createNewMenuItem());
                 menu.add(createOpenMenuItem());
                 menu.add(createCloseMenuItem());
                 menu.add(createSendToMenu());
              
                 return menu;
              }
              ...
              // etc.etc. etc.
              kind regards,

              Jos
              I'm still not understanding the main part - JMenu createFileMenu( ) {
              JMenu menu= new JMenu("File");

              Does this create a pull down menu?

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by Bucs44
                I'm still not understanding the main part - JMenu createFileMenu( ) {
                JMenu menu= new JMenu("File");

                Does this create a pull down menu?
                Yup, and you add that menu to the menu bar. You can add menus or menu
                items to the menu itself. Read the API documentation for those classes.

                kind regards,

                Jos

                Comment

                Working...