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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:16:13+00:00 2026-06-07T06:16:13+00:00

As mentioned here: Adding Components to the Content Pane , The default content pane

  • 0

As mentioned here: Adding Components to the Content Pane,

The default content pane is a simple intermediate container that
inherits from JComponent, and that uses a BorderLayout as its layout
manager.

and here is a proof:

JFrame frame = new JFrame();
LayoutManager m = frame.getContentPane().getLayout();
System.out.println(m instanceof BorderLayout); // prints true

However, can you explain the output of the following code?

JFrame frame = new JFrame();

LayoutManager m = frame.getContentPane().getLayout();
System.out.println(m);
System.out.println(m.getClass().getName());

LayoutManager m2 = new BorderLayout();
System.out.println(m2);
System.out.println(m2.getClass().getName());

OUTPUT:

javax.swing.JRootPane$1[hgap=0,vgap=0]
javax.swing.JRootPane$1
java.awt.BorderLayout[hgap=0,vgap=0]
java.awt.BorderLayout
  • 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-06-07T06:16:15+00:00Added an answer on June 7, 2026 at 6:16 am

    this explains your result:

     protected Container createContentPane() {
            JComponent c = new JPanel();
            c.setName(this.getName()+".contentPane");
            c.setLayout(new BorderLayout() {
                /* This BorderLayout subclass maps a null constraint to CENTER.
                 * Although the reference BorderLayout also does this, some VMs
                 * throw an IllegalArgumentException.
                 */
                public void addLayoutComponent(Component comp, Object constraints) {
                    if (constraints == null) {
                        constraints = BorderLayout.CENTER;
                    }
                    super.addLayoutComponent(comp, constraints);
                }
            });
            return c;
        }
    

    The method creating the contentpane creates an anonymous inner class that inherits from BorderLayout.
    So testing on instanceof will return true but its another class so the class name is different.

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

Sidebar

Related Questions

As I mentioned here , I'm trying to generate HTML from an ASPX page
I am using John resig's implementation class mentioned here: http://ejohn.org/blog/simple-javascript-inheritance/ Now I have a
I get the error mentioned here: C++ Templates Error: no matching function for call
I am using git configuration mentioned here If I create a new tab and
I can't see it as mentioned here: http://www.c-sharpcorner.com/uploadfile/mahesh/dll12222005064058am/dll.aspx Do I have to activate somehow
I was wondering about the last constructor for std::string mentioned here . It says:
I am new to SQL Server 2008 fill factor, as mentioned here in SQL
I have followed this tutorial here as mentioned exactly I now try to run
Itest is an Interface. here i mentioned like new Itest(). Then is it means
I know that can co-exists with web form no problem as Hanselman mention here

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.