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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:26:45+00:00 2026-05-13T09:26:45+00:00

I am developing a Java Desktop Application. In the GUI, I want that user

  • 0

I am developing a Java Desktop Application. In the GUI, I want that user can add as many toolbars dynamically as he wants. To implement this, the following are the things that I have done already:

  • Have taken a mainPanel and set its layout as BorderLayout
  • Then taken a topPanel and added it to the mainPanel’s BorderLayout.NORTH
  • set the topPanel’s layout as BoxLayout
  • Then taken 5 panels named toolbar1Panel, toolbar2Panel, ….
  • Afterthat, have added one toolbar to each of the toolbarPanel created in the previous steps.
  • Have added only one toolbarPanel i.e toolbar1Panel on the topPanel

Now there is a button named “Add” on the first toolbar which is added on the “toolbar1Panel” which in turn is added to the topPanel.

Now I have implemented the “actionPerformed()” method of the above “Add” button as follows:

// to add second toolbar Panel to the topPanel dynamically
topPanel.add(toolbar2Panel);  

But the problem is that it is not working. Means there is no toolbar added to the topPanel.

Is there anything which I am missing.

The code is Netbeans Generated so I think it would only add mess for others, that’s why I haven’t pasted any code here.

  • 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-13T09:26:45+00:00Added an answer on May 13, 2026 at 9:26 am

    After adding another toolbar to the BoxLayout, you may need to (re|in)?validate the panel.

    I’ve done this repeatedly but I can’t understand the logic behind the 3 or so method calls; so I just try them until I hit on the one that works:

    topPanel.validate();
    topPanel.invalidate();
    topPanel.revalidate();
    topPanel.layout();
    

    (at least) one of those should force your GUI to re-calculate its layout, making the north panel larger and thus showing the 2nd (and successive) toolbar(s) you’ve added.

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

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One way to mitigate the server load would be to… May 13, 2026 at 5:57 pm
  • Editorial Team
    Editorial Team added an answer I'm going to go for the trite answer and just… May 13, 2026 at 5:57 pm
  • Editorial Team
    Editorial Team added an answer Don't reinvent the wheel. [Edit: updated for 2014, now linking… May 13, 2026 at 5:57 pm

Related Questions

I am developing a Java desktop application and would like to have an external
I am developing a Java based desktop application. There are some data generated from
I am developing a desktop app using Java and Swing Application Framework. I have
I am using a quad-core windows XP based Dell Machine machine in my office
Am coding an AIR 1.5 app in which I want to do a remote

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.