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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:50:41+00:00 2026-05-27T17:50:41+00:00

One of my classes is returning a JPanel which is added on a JFrame

  • 0

One of my classes is returning a JPanel which is added on a JFrame by some other class.
The JPanel contains a JTree and some buttons. On some events the panel is created again and returned to the JFrame.

My problem is that I have to add the JPanel to the Container of the JFrame again and then resize the frame for changes to be visible. I can’t figure how to have the frame update without resizing.I tried removing old objects and adding updated ones but still doesn’t work.

What is the best way to deal with this issue? Ideally I would have a reference to the JPanel and when the JPanel is changed, the frame will also be updated.

  • 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-27T17:50:42+00:00Added an answer on May 27, 2026 at 5:50 pm

    The whole model is changing not just its data. I will probably change this in the future but for now when data change a new JTree is created

    Then your code should be something like:

    JTree tree = new JTree( theNewModel );
    scrollPane.setViewportView( tree );
    

    That is you need to add the new JTree to the GUI, you can’t just change the reference to the tree variable.

    Or even easier, you don’t need to create a new JTree, just replace the model in the existing tree using:

    tree.setModel( theNewModel );
    

    If this still doesn’t help then you need to post your SSCCE that demonstrates the problem because your question still isn’t clear.

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

Sidebar

Related Questions

I have two classes one of which inherits from the other. Im trying to
One of my base repository classes contains a method: public abstract class RepositoryBase<T, TDb>
One of classes in my program uses some third-party library. Library object is a
I am using System.Timers.Timer class in one of the classes in my application. I
I have a class library. In one of the classes, I am adding a
I have a data layer which is returning lists of classes containing data. I
I have a class with several variables, one of which is a hash (_runs):
I'm executing the java binary from one of my classes, and a ClassNotFoundException gets
I have a field for addedBy in one of my classes. I've set up
Trying to override a tostring in one of my classes. return string.Format(@ name =

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.