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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:34:20+00:00 2026-05-28T23:34:20+00:00

I have a problem when I click a button to change the content of

  • 0

I have a problem when I click a button to change the content of right_pan(JPanel) nothing happens;
I have 3 JPanel:
pan_glob therein lies the other two:
right_pan and left_pan(are integrated into the main JFrame named “main” see screenshot),and another external JPanel named cree_client (contains text box).

enter image description here

I’d like when I click a button, the content of cree_client(JPanel) is loaded into right_pan(JPanel).

I tried this but it does not work :

  private void jMenuItem23ActionPerformed(java.awt.event.ActionEvent evt) {

  cree_client cc=new cree_client();
  this.right_pan.removeAll();
  this.right_pan.validate();
  this.right_pan.add(cc);
  this.right_pan.revalidate();

}

ANY helps ?

  • 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-28T23:34:21+00:00Added an answer on May 28, 2026 at 11:34 pm

    First rule of using any UI toolkit: don’t remove/add children to control visibility. It never works very well in almost any UI toolkit. It requires more work on the toolkit to properly handle it, and that goes double for Swing. Instead use either visibility, or I bet what you should use is a CardLayout. A panel with a CardLayout will allow you to flip between several screens:

    public class StackPanel extends JPanel {
    
        CardLayout layout = new CardLayout();
        public StackPanel() {
            super();
            setLayout( layout );
        }
    
        public addStack( String name, JComponent child ) {
            add( name, child );
        }
    
        public void showStack( String name ) {
            layout.show( this, name );
        }
    }
    
    
    CardLayout layout = new CardLayout();
    StackPanel stack = new StackPanel();
    stack.addStack( "panelOne", panelOne );
    stack.addStack( "panelTwo", panelTwo );
    ...
    JButton someButton = new JButton( new AbstractAction("Next" ) {
        public void actionPerformed(ActionEvent evt ) {
           stack.showStack( "panelTwo" );
        }
    } );
    

    If you don’t want to flip between two or more screens, then you can use setVisible() to hide and show the different screens just as well.

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

Sidebar

Related Questions

I have a problem when assigning functions to the click event of a button
I have a list showing up when I click on button, the problem is
I have problem with change of tab panel layout by click event on buton
I have a problem with an animation in jQuery using ajax. On the click
I have a problem... In my view i have Image.If i click on image
i have this annoying problem with my site where, when you click on a
Problem I have Telerik TabControl and each tab content is a partial view. Everything
I have navigation menu that once the user click then change and fade the
In my app i have a button that when click loads a new image
I have the following simple button with an image as the template. The problem

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.