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 6695161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:11:18+00:00 2026-05-26T06:11:18+00:00

Set up: I have a mainPanel with a tabbedPane on it, i have a

  • 0

Set up:
I have a mainPanel with a tabbedPane on it, i have a separate JPanel ‘extra’, extra creates an objects and i wish to pass that object back through to the mainPanel where i can actually use it/add it to the data structure.

Frame > Panel > TabbedPane > Panel (Separate Class, instantiated as new object)

I tried to add a listener in mainPanel that checks if a boolean in PanelExtra changes and then runs a method etc, but it didn’t work.

I would make a method in mainPanel to accept the object but i don’t know how to refer back to it. (getRootPane() didn’t return anything)

Also im not sure if im using correct terminology, while i was taught Java in a command line Unix environment, Swing is very new to me.

I tried Listeners, Observers and am currently considering an object created at root and passed DOWN through all objects (As java passes by reference, i could pass information back as far as i want) If that isn’t an entirely stupid idea, let me know and we can all go about our lives. If there is a better way to do it that’d be great.

(File overview)

[programApp]>[programView>tabbedPane]>[panel]
Panel is created using new, and exists in a separate class.
I want to pass data back from Panel to programView (projectNameView as it is in netbeans)

I will attempt to add as much information as i can.

  • 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-05-26T06:11:18+00:00Added an answer on May 26, 2026 at 6:11 am

    You can use the MVC-pattern for that.

    Actually there are couple of variants depending on your preferences or exact task.
    For very simple case you can just use class with static fields to pass objects.
    Another way is to define your own listeners like:

    private myPanel extends JPanel implements Notification {
    

    …
    and where you create that panel:

    myPanel.addNotificationReciever(mainPanel);
    

    Later you just call fireNotification or whatever and implement similar listener for your mainPanel.

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

Sidebar

Related Questions

I have set up a Django application that uses images. I think I have
I have a style for a textblock that is set inside my app.xaml this
I have set location (0,0) for the JLabel with respect to the JPanel. But
I have two panels: main_panel child_panel The main_panel layout is set using: main_panel.setLayout(flowlayout) I
We have set up a system where notifications get sent to a user with
I have set a canvas' background to an image of a company logo. I
I have set up transactional replication between two SQL Servers on different ends of
I have set up a version control system using TortoiseSVN at my home to
I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when
I have set the itemRollOver and itemRollOut event listeners on a List component, but

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.