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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:52:01+00:00 2026-06-10T05:52:01+00:00

ContainerPanel is a custom JPanel class using a BorderLayout . The SOUTH contains a

  • 0

ContainerPanel is a custom JPanel class using a BorderLayout. The SOUTH contains a JPanel with a button. I want the CENTER to be an instance of another custom JPanel, say AbstractPanel, which provides an abstract method which will be called when the button is clicked. I also want to set this JPanel programmatically (at run-time). So far, I can do all of this as you can see in the following code (some of which is generated by the NetBeans GUI Builder):

package jpaneldemo;

import java.awt.BorderLayout;

public class ContainerPanel extends javax.swing.JPanel {

    public ContainerPanel() {
        initComponents();
    }

    public ContainerPanel(AbstractPanel abPanel) {
        initComponents();

        this.abPanel = abPanel;
        this.add(this.abPanel, BorderLayout.SOUTH);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private void initComponents() {

        buttonPanel = new javax.swing.JPanel();
        okButton = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
        buttonPanel.add(okButton);

        add(buttonPanel, java.awt.BorderLayout.PAGE_END);
    }

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
        this.abPanel.abstractMethod();
    }

    // Variables declaration - do not modify
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JButton okButton;
    // End of variables declaration

    private AbstractPanel abPanel = null;

}

I also created the AbstractPanel class:

package jpaneldemo;

public abstract class AbstractPanel extends javax.swing.JPanel {

    public AbstractPanel() {
        initComponents();
    }

    protected abstract void abstractMethod();

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }
    // Variables declaration - do not modify
    // End of variables declaration
}

Now I want to create subclasses of this AbstractPanel class which I can edit in the NetBeans GUI. Typically, I right-click on a package name in the Projects window and then navigate to “New -> JPanel…” to create a custom JPanel. How do I get AbstractPanel to appear in the “New” menu so that I can edit the new class with the NetBeansGUI Builder? Or is there another way to accomplish the same thing?

  • 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-10T05:52:03+00:00Added an answer on June 10, 2026 at 5:52 am

    If your intention is to provide a “template” component that can then be added to the palette and included in other containers, then yes you can.

    Have a read through FaqFormCustomContainerBean

    The basic idea (apart from creating a BeanDescriptor is you will need to provide a “content” panel of some kind, where additional content can be added at design time.

    Now, if you’re interested in providing a custom template, that’s something I’ve not done before.

    You could try reading through http://netbeans.org/competition/win-with-netbeans/customize-java-template.html. It may be a little out of date, but might help you in the right direction

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

Sidebar

Related Questions

i am writing a stand alone app in java using a couple of JPanel
I am using YUI Panel http://developer.yahoo.com/yui/container/panel/ to design an application. I want to execute
I wrote a custom Control (an auto-complete TextBox (below)) in which a ContextMenuStrip is
I'm trying to make tabs and am using easytabs. By the below code, the
There is 1 Div-container, into which I want to render my full application. The
I need to pick a standard container (JPanel?) in Swing that I can use
I have a panel sitting in a div, and I want to use that
I have a panel with a vbox layout. I want to add a panel
I have a custom form that has 4 panels on it edges. I would
I have a ContainerPanel to which I added a UserControl. Is there a way

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.