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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:16:23+00:00 2026-05-12T15:16:23+00:00

I have a JFrame with a JPanel on it. I want to add another

  • 0

I have a JFrame with a JPanel on it.

I want to add another JPanel which is a preconfigured component onto the Jpanel inside my JFrame.

If I do this:

    subPanel.setLayout(new BorderLayout());
    subPanel.add(preconfiguredPanel,BorderLayout.CENTER);

my Panel will show.

If I do this:

    subPanel.add(preconfiguredPanel);

my JPanel will not show. The documentation says when using add(Component) it will use the default Layout FlowLayout. Ok fine, but why won’t my component display inside that JPanel when using the default FlowLayout???

  • 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-12T15:16:23+00:00Added an answer on May 12, 2026 at 3:16 pm

    Probably because your panel doesn’t have a preferred size.

    When you add a panel to a BorderLayout the default is to place it in the center, so the panel will automatically be resized to the size of the frame.

    When you add the panel to a FlowLayout, the flow layout repsects the size of the panel.

    If you need more help then post your SSCCE.

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

Sidebar

Related Questions

I want to add Scrollpane to JPanel which is in turn called by another
I have a JFrame(frm) in which I've added a JPanel (pnl1)..which in turn has
I have a JFrame with JScrollPane in it. I have JPanel inside a scrollPane.
I Have two files. One extends JFrame, and another Extends JPanel. Whenever I change
So I have a JFrame , in which it has a bunch of JPanel
I have a JPanel that I want to add some components. in particular JButton
I have a JPanel inside a JFrame . I have registered a KeyListener ,
I have a JFrame and a Jpanel over that in which various buttons are
I have a JFrame and In which I want to show a JInternal Frame
Again... I have another issue with the keyListener and the JFrame. I want to

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.