Urgent.. How to add a menubar to a frame by reading a file

Hi All,
I am involved in a project where in i need to add a menubar to the frame by reading a text file. The text file consists of all the Menu Items and subMenu items.This text file will be a editable file where-in the user can add his own menu-items.
i.e when i run the java program i should read the menu items from a file and then display those menuitems in the Menubar.
I am not getting the idea how i should proceed. Can any one help.
Thanks in advance.
Regards
Ravi Kumar

Sorry again - my use of i as an array index wasn't very clever. The post should have been as follows:
Hi,
You can read in the menu names from the file and add them fairly simply, with something like this:
JMenuBar jmb = new JMenuBar();
JMenu myMenu = new Jmenu("Custom");
jmb.add(myMenu);
in = new BufferedReader(new FileReader("file.txt"));
JMenuItem [] menulist = new JMenuItem[MAXITEMS];
for (int j=0; j < MAXITEMS; j++) {
menulist[j] = new JMenuItem(in.readLine());
myMenu.add(menulist);
Then add the JMenuBar to the parent frame.
However, for the menus to be of much use, you'd need to add actionlisteners to them as well.
If you had a set of possible menu items, and it was just a question of which order the user's file defined them in, and which it used, you could then just test the name of each item in the file and assign an appropriate class of actionlistener to it, something like:
if(menuitem.getText().equals("Open")) {
menuitem[j].addActionListener(new OpenActionListener());
where you'd defined the OpenActionListener class somewhere else.
Hope this helps,
Neil
http://www.theBatCave.org.uk
(Not having a very good day!)

Similar Messages

  • How to add HTTP Header Response X-Frame-Options:SAMEORIGIN from OWA published via Forefront TMG 2010 to stop Clickjacking

    How to add HTTP Header Response X-Frame-Options:SAMEORIGIN from OWA published via Forefront TMG 2010 to stop Clickjacking. I have put the IIS setting X-Frame-Options:SAMEORIGIN  on my Internal CAS Server. However as the OWA page is published through
    Forefront TMG 2010, the iFrame tag is not blocked when the page is first opened. Only when you login with your credentials to the OWA page inside the frame and the page reaches IIS on the Internal CAS it gets blocked. I want to block it in the first
    instance when it is opened from TMG.

    Hi,
    Thank you for the post.
    To modify the http header, please refer to this blog:
    http://tmgblog.richardhicks.com/2009/03/27/using-the-isa-http-filter-to-modify-via-headers-and-prevent-information-disclosure/
    Regards,
    Nick Gu - MSFT

  • How do i export a single jpeg frame from a video file in final cut x

    how do i export a single jpeg frame from a video file in final cut x

    You can also use the 3 finger method of COMMAND+SHIFT+4, then drag across what you want to copy from the image. That will show up on your desktop, which then you can edit using Photoshop, if you want too.
    You can then change the file format from a PNG to either a .JPG or TIFF or even a Photoshop image.
    Make sure, you have stopped the playback, to what you want to save as a still.
    Either method works, to make a still image from video.

  • Urgent - How to add a new control instead of tabs in JTabbedPane

    Hi,
    Please give me an idea or a sample program for how to add a new control
    in JTabbedpane instead of tabs that means overlay any Java controls or pane
    in the tabpane empty place next to tabs

    "Urgent" is not relevant to the question. Your question is no more important than anybody elses.
    My answer in this posting show a limited solution:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=636289
    Otherwise I suggest you try using a layered pane approach:
    http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html

  • PLz Help me its urgent, how to add new field in mm01 basic data screen

    Hi everyone,
         plz tell me how to add new field in mm01 basic data screen,i added that field in basic data screen but when i create a material the data for that field will not save in database table.
    Thanks,
    murali.

    Hi Murali,
    when created added a field on the screen by using user exit then after that you have add the field in main table where you will be getting these table in the userexit only, please make sure about this. And i am sure defenitly it will get updated in to the table.
    reward if useful.
    thanks
    abdulsamee.

  • Urgent: How to add  reference DTD at receiver side XML?

    Hi!
    I have a problem to transfer IDOC to XML.
    During Migration from Business connector to XI 3.0,
    At original result xml header,
    ....<?xml version="1.0" encoding="ISO-8859-1"?>
    ....<!DOCTYPE Shipments SYSTEM "DTD/Shipment.dtd">
    .................................~~~~~~~~~~~~~~~~~~~~~~~~~~~
    But, thru XI,
    ....<?xml version="1.0" encoding="iso-8859-1"?>
    ....<!DOCTYPE Shipments>
    so, target system can't recognize that result xml.
    we are using mapping program with abap-class, XI3.0 SP14.
    How to add it at xml header in abap class?
    regards
    Message was edited by: ChangSeop Song

    Hi,
    I don't know if this will work
    but I'd try with xslt and <b>doctype-public</b> and <b>doctype-system</b> declarations to do what you want
    in the second mapping (after the abap mapping)
    of the interface mapping that you're using
    Regards,
    michal

  • Urgent - How to add buttons to a Table

    How to add buttons to a Table and enable them for Mouse Listeners/ Action Listeners

    extends the defaultcellrenderer make it return a Jbutton as the component to draw.
    class OverCellRendererClass extends DefaultTableCellRenderer {
    public Component getTableCellRendererComponent(JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row,
    int column) {
    //put your stuff here to make or get a button
    return myButton;
    Use something like this to set the renderer for the column :
    tb.getColumnModel().getColumn(4).setCellRenderer(new YourCellRendererClass());

  • How to add a new right-click menu entry in Nautilus file browser?

    I want to add a couple of new context menu entries to Nautilus File Browser.
    So when I e.g. right-click in View Pane on a file "foobar.conf" an menu entry "edit with gedit" should appear (among the other default entries).
    When clicked the file "foobar.conf" should be passed to gedit (and gedit editor opened).
    How can I achieve this?
    Under Ubuntu there are nautilus-actions but when I try to install them in Solaris with
    pkg install nautilus-actions
    then this package is not found.
    How else can I create my own context menues?
    I would appreciate to have one script with all my context menus, which when run add them all in one step.

    To manage selected files or directories, you can use specific Nautilus variables like NAUTILUS_SCRIPT_SELECTED_FILE_PATHS.
    For more details and which variables exist, please read the content of the following URL :
    Nautilus File Manager Scripts: Questions and Answers

  • Does anyone know how to Add a date drop down list to a pdf file?

    Can someone tell me how to add a Date drop down list in a form

    There's no built-in function that does that in Acrobat, but there are some third-party tools that do.
    The two most known ones are by FormRouter, which is free and based on form fields (but also a bit buggy), and a non-free version created by Max Wyss, which is based on a dialog object.

  • How to add scrollbar to the JInternal Frame

    How to add scrollbar to JInternal Frame?
    I have One JInternal frame i want it should have a scrollbar when we reduces its size.

    [url http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html]How to Use Scroll Panes

  • How to sign MIDlet so it wont confirm before read/write file operation ?

    hi there,
    i am developing application which reads mp3 files from the songs folder. but at each run of my application it ask the confirmation to Allow to read and write file to application.
    how can i othorize or sign my MIDlet to overcome this problem ?
    i m using Sony Z550i phone.

    on some J2ME platforms you may have to sign the applet to set the option to Always Allow.
    Under NetBeans all you have to do to sign the app is go to the Projects window, right click on the desired project, select Properties. A Project Properties window will pop-up. On the left hand side, near the bottom, select Signing. Select the check box labeled 'Sign Distribution'. By default there is a 'built-in keystore' that should work with many J2ME platforms but you can also generate your own keystores through the Security Manager.
    If you wish to generate your own keys:
    WARNING: may not work with all J2ME platforms if you are not able to authorize the key on the platform you wish to run it on.
    Beside the 'Sign Distribution' checkbox there is a button labeled 'Open Security Manager'. There you click 'Add Keystore'. Fill in a password and it will create your keystore. Next, select the newly generated keystore and click the 'New' button to add keys to the keystore. Simply fill out the form and it will generate a key for you.
    When you build using NetBeans it may ask you for the keystore and signing key passwords again, so make sure you use a password you will remember.

  • URGENT : How to add spaces in the outbound file

    Hi Gurus,
    I am writing data from SAP to a Unix file via an ABAP program.
    The file has one record with 4000 characters with 2000 spaces in between the datas.
    Is there any command to add these spaces ? Or I have to go through a loop to add them ? I cannot leave them and assume that they will be spaces by default,as this is causing some error in Unix side.
    Please help,this is urgent.
    Regards,
    Sandip.

    heyy i could find the solution to it....so am closing the thread..thanksss

  • Urgent: How to add BEx Reports to Role

    Dear all,
    I have created BEx reports and they are present in INFOAREA tab in Query Designer and Analyser.
    Now I want to assign these reports to Role area. I have tried thru tcode PFCG but couldn't find the solution.
    Please help me in finding the solution. Its urgent.
    Thanks in advance.
    Vinod.

    hi Vinod,
    check
    add query in role
    you can try,
    in PFCG, click '+other', choose 'bw query url', in next screen give description for text and object description =
    <bsp_protcl>://<bsp_server>/sap/bw/BEx?sap-language=<language>&bsplanguage=EN&cmd=ldoc&INFOCUBE=infocubename&QUERY=querytechnicalname
    or open Query Designer, find your query,
    before open the query click button “Enter in Role”.
    select role/folder in which you want to put the query
    hope this helps.

  • Urgent: How to add event listeners to a null object?

    I have an object that is lazy loaded, and therefore starts out null.
    How can I add an event listener onto this null object, so that it fires whenever the object is instantiated?
    WHY does arrayCollection.addEventListener(CollectionEvent.COLLECTION_CHANGED, function) not work??
    Thanks!
    C

    C,
    the answer to your question "WHY does arrayCollection.addEventListener(CollectionEvent.COLLECTION_CHANGED, function) not work??" is that addEventListener is not a static method, ie it has to be attached to an actual instance. I agree that in your situation it would be handy to have it as static, something like ArrayCollection.addEventListener(etc) but I'm not at all sure that is a good plan in general, as usually we want events to fire from an actual instance of the class, not generically. A quick look through the adobe docs has convinced me there are not many static methods at all, and none that appear to help you.
    I take it from your description that you don't know exactly when the collection is instantiated? But presumably though you do have a point where new is called? Or something equivalent like populating it from something else?
    Richard

  • Urgent:how to add two table regions to one query region

    hello
    In my page a serach region is there and for that region i need to add two tables and two are based on two different view objects.how can i implemnet this thing please let me know.
    advance thanks

    Hi Wei Fang,
    You can try by creating a 2 line template (1 Template, 2 linetype) under a loop note.
    So your smartform tree structure will be shown like this:
    LOOP
        TEMPLATE1.
    On the LOOP part, pass the internal table of your data to the working areas.
    On the template put all the data of the summary on your first linetype, and put
    the detail data on your second linetype.
    Good luck and hopefully this will solve the problem
    Edited by: Prawira Fadjar on Oct 22, 2008 10:04 AM

Maybe you are looking for