Search code examples
javaswingjpaneljmenujmenubar

loading multiple files using the options from menu bar in java


I have developed an editor using java Jpanel, component, etc....I have 2 text areas in the editor. When i choose open a file option from the menubar i'm able to load the content of the file to one textarea. But how can i add another option to the menu bar to load the content of another file to the second text box?


Solution

  • You can add two menu items, passing a reference to the desired destination text area to each Action. Alternatively, depending on your design, add a single menu item whose Action alternates between the two destination text areas.