This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Implementing listeners to menu events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Implementing listeners to menu events" Watch "Implementing listeners to menu events" New topic
Author

Implementing listeners to menu events

Steven Thomas
Greenhorn

Joined: Nov 15, 2011
Posts: 1
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.
Haina Minawa
Ranch Hand

Joined: Oct 13, 2011
Posts: 119
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
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing listeners to menu events
 
Similar Threads
Creating a tab menu
JSP with tabs
Tabbed Panel design pattern
Best Framework for Tabbed Dialogs
JPopMenu and TabbedPane