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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:00:37+00:00 2026-06-11T10:00:37+00:00

I have a subclass of JFrame A. I have another class B which is

  • 0

I have a subclass of JFrame A. I have another class B which is the subclass of A. I want to add new components to frame B like JButtons. My code is as follows:

public B() extends A {
    //Calling super class constructor
    super();

    //Creating and adding a button 
    JButton btn = new JButton();
    this.add(btn);

    //other codes
}

When I display the frame, the button isn’t added, and only the superclass frame and its components are displayed. How can I add those buttons in the subclass B’s frame?

Update: Here is a condensed version of my code. I’ve used BorderLayout in super class ListObjects.

package assignment2;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ListAndModifyCustomer extends ListObjects {

public ListAndModifyCustomer() {
    //Calling super class constructor
    super("Customers");

    //Adding listener to the ok button
    super.selectBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            //codes to create another JFrame

            dispose();  //Closing the frame
        }
    });

    //Adding button to the panel
    super.panel.add(new JButton("NO"));

    JPanel jp = new JPanel();
    jp.add(super.selectBtn);

    super.add(jp, BorderLayout.SOUTH);
}
}
  • 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-11T10:00:38+00:00Added an answer on June 11, 2026 at 10:00 am

    I found out that if we create a panel in the subclass and add all the items to that panel and add that panel to the frame of the super class then the components become visible.

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

Sidebar

Related Questions

I have a subclass of UITableViewController. I have code that can add/remove a UISearchBar
I have a subclass of an NSManagedObject, and I'd like to add a couple
I have a subclass of NSWindowController that has its own nib and another class
I have subclass a UITableViewCell as follows: @class MyCell; @protocol MyCellDelegate - (void) viewController:(MyCell*)viewCon
I have a subclass and I want it to not include a class attribute
I have a JPanel subclass on which I add buttons, labels, tables, etc. To
I have a subclass of uiviewcontroller,and implemented the delegate UITableViewDelegate and UITableViewDataSource.my code like:
I have a class called ToolbarView which is a subclass of UIView and basically
HI All. I have subclass of UIScrollView. IN this class I have added some
Say, you have a subclass of JFrame , and use it to create your

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.