Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 110111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:10:32+00:00 2026-05-11T02:10:32+00:00

Edit–@Uri correctly pointed out that this was an abuse of annotations; trying to actually

  • 0

Edit–@Uri correctly pointed out that this was an abuse of annotations; trying to actually create the menu data itself in annotations is just silly.

They are good for binding however, I think I’ll stick with using them to link the text data to the methods (the @Menu (‘File’) portion) since it’s more explicit and flexible than reflecting to a method name. Also I learned quite a bit in messing with it. I’ll post the code here in a few days as an answer.

–original post–

I haven’t used these new-fangled annotations, but they look amazingly interesting. I’m having trouble figuring out the syntax though (or more appropriately, the best way to use it).

In writing some code in response to this question It occurred to me that my methods are quite outdated.

I used to parse a string to define my method structure, then use reflection to pass it out to classes, but I think annotations could make a much better menu structure.

I’d like to replace my test class in the file with something like this:

@TopMenu('File,Edit') @Menu(name='File','Save,Load,Print,Preview,Quit') @Menu(name='Print','Preview,Print') @Menu(name='Edit','Copy,Paste')  public class TestMenu {     @MenuItem ('Save')     public void save() {         System.out.println('saved');     }     @MenuItem ('Load')     public void load() {     System.out.println('loaded');     } ... 

and pass the entire class off to a method that manufactures and returns a JMenuBar bound to the class instance with no further input.

First problem is that I can’t figure out how to pass a ‘Default’ of a string, they all want to have (attribute=’value’) instead of just (‘value’), can this be done? I can live without it, but it’s a little verbose. It’d be even better if I could get rid of the parens and/or quotes, but I’m not holding my breath (I think to do that I’d have to define an individual interface for each menu item, that’s not acceptable).

Secondly it doesn’t like the multiple @Menu tags on a single class. I could get around this by parsing a single string, but I was wondering if there was another way.

Most importantly, is there a library that does this already? (If nobody comes up with one, I’ll publish code to this thread when I get it working in case anyone else is interested.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:10:33+00:00Added an answer on May 11, 2026 at 2:10 am

    The way I’ve seen multiple annotations attached is to use a container annotation, and then specify the items as an array.

    @Retention(RetentionPolicy.RUNTIME) public @interface Menu {     String name();     String[] children(); }  @Retention(RetentionPolicy.RUNTIME) public @interface MenuBar {     Menu[] value(); }  @Retention(RetentionPolicy.RUNTIME) public @interface MenuItem {     String value(); }  @MenuBar(     {         @Menu(name='File', children= {'Save','Load','Print','Preview','Quit'}),         @Menu(name='Print', children= {'Preview','Print'}),         @Menu(name='Edit', children= {'Copy','Paste'})     } ) public class TestMenu {     @MenuItem ('Save')     public void save() {         System.out.println('saved');     }      @MenuItem ('Load')     public void load() {         System.out.println('loaded');     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You don't need to create numpy arrays to call numpy.std().… May 11, 2026 at 10:09 am
  • added an answer I have a Python script to make moving around a… May 11, 2026 at 10:09 am
  • added an answer select t1.make, t1.model, t1.year, t1.other_cols from table t1 where year… May 11, 2026 at 10:09 am

Related Questions

Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
EDIT: This question is more about language engineering than C++ itself. I used C++
EDIT What small things which are too easy to overlook do I need to
Edit : Solved, there was a trigger with a loop on the table (read
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
Edit: I have solved this by myself. See my answer below I have set

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.