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

  • SEARCH
  • Home
  • 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 7907847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:39:59+00:00 2026-06-03T11:39:59+00:00

I have created 3 panels. In the root panel I have added JTabbedPane ,

  • 0

I have created 3 panels.
In the root panel I have added JTabbedPane, inside one of the tabs I have added second Panel with BorderLayout and finally in the BorderLayout.WEST the 3rd one.
Inside the 3rd one I have added a JTree with PopupMenu.

How can I get root panel inside actionPerformed of PopupMenu?

menuItem.addActionListener(new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
        System.out.println("one:"+tree.getParent().getName());
        System.out.println("two:"+tree.getParent().getParent().getName());
        System.out.println("three:"+tree.getParent().getParent().getParent().getName());
        new UnzipFile(file, file.getParentFile(),
        (rootPanel) tree.getParent().getParent().getParent() ).run();
    }
});

output:

Exception in thread "AWT-EventQueue-1" java.lang.ClassCastException: de.util.scanners.view.FileTreePanel
at de.util.scanners.view.FileTreePanel$2$1.actionPerformed(FileTreePanel.java:109)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1050)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1091)
at java.awt.Component.processMouseEvent(Component.java:5517)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
one:null
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
two:null
three:null
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at be.azvub.webutil.gui.WebEventQueue.dispatchEvent(WebEventQueue.java:34)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
  • 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. Editorial Team
    Editorial Team
    2026-06-03T11:40:00+00:00Added an answer on June 3, 2026 at 11:40 am

    You could use the SwingUtilities.getAncestorOfClass method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a JLabel lab1. Added it to a panel and added mousemotionlistener
I have created a UserControl that has 3 panels. What I what to do
I have a responsive layout and I've created a fading panels animated element with
I have a created a panel. This has autoscroll = true At the start
I have created a Dynamic View Panel custom control and want to add a
I have created a Treeview and used a stack panel to include a checkbox,
I am using my admin panel login script where i have created a global.php
I created a window using the design panel in JFrame, it didn't have any
I have a button that is programatically created, it's content is a stack panel
I have a plesk panel and root dedicated server on 1and1. I'm using custom

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.