• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Implementing listeners to menu events

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JDesktop --> with multiple JInternalFrames with tabbed panes (each with completely different data calendar, todo list, reminder, notes)
I have added a MenuBar to the main JFrame
One of the menu items is "Print"

When the user clicks Print from the menu I would like the "print function" of the active JPanel in the tabbed pane to act on the print command.

Not sure Java can do this is elegantly. Any help is appreciated.
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steven Thomas wrote:

Not sure Java can do this is elegantly. Any help is appreciated.



Surely Java can do that. Take a look at: How to use menus
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steven Thomas wrote:I have added a MenuBar to the main JFrame


Please tell me you meant JMenuBar instead of MenuBar... You shouldn't mix AWT components like MenuBar with Swing components like JFrame.

When the user clicks Print from the menu I would like the "print function" of the active JPanel in the tabbed pane to act on the print command.


JDesktopPane has method getSelectedFrame() which returns a reference to the currently active JInternalFrame. Use it to get its JTabbedPane, which has method getSelectedComponent() to get the currently active Component (the one you added with addTab or insertTab).
reply
    Bookmark Topic Watch Topic
  • New Topic