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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:17:56+00:00 2026-05-29T22:17:56+00:00

I am designing an application in NetBeans, as illustrated in the screenshot below. When

  • 0

I am designing an application in NetBeans, as illustrated in the screenshot below.

enter image description here

When the user clicks on a JButton on a JFrame, a JDialog pops-up asking the user to enter a numeric value using a numeric keypad. I would like the JDialog to dynamically add 2 JPanels. JPanel 1 will contain a textbox for input. JPanel 2 will contain a numeric keypad. I designed them this way so that I could reuse the numeric keypad whenever I need it. The problem I am facing is displaying dynamically these 2 JPanels on the JDialog that pops-up. JDialog pops-up empty. Please take a look at my code below. Thank you all, I appreciate your help

This is the sample code of JDialog:

public class MyDialog extends javax.swing.JDialog {

    public MyDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {//Add JPanel 2 (Numeric Keypad) to JDialog
                Container contentPane = getContentPane();
                NumericKeypadPanel nkp = new NumericKeypadPanel();
                nkp.setLayout(new java.awt.BorderLayout());
                contentPane.removeAll();
                contentPane.add(nkp);
                contentPane.validate();
                contentPane.repaint();
            }
        });
    }

This is the sample code for JPanel 2 (Numeric Keypad):

public class NumericKeypadPanel extends javax.swing.JPanel {

    /** Creates new form NumericKeypadPanel */
    public NumericKeypadPanel() {
        initComponents();//Draws 10 number buttons
    }
}
  • 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-29T22:17:56+00:00Added an answer on May 29, 2026 at 10:17 pm

    basicall there are two ways

    1) add a new JComponent by holding JDialog size (in pixels) on the screen, all JCompoenets
    or part of them could be shrinked

    2) resize JDialog by calling pack(), then JDialog will be resized

    both my a.m. rulles works by using Standard LayoutManagers (excepting AbsoluteLayout)

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

Sidebar

Related Questions

Say you’re designing an application that, by requirement, allows a user the flexibility of
I am designing an application where the user selects the option to update his
I am designing an application where a user places multiple UIImageViews one over another.
When you are designing an application (assumed in English), and you ask the user
I am designing an application that will display dynamically-generated forms to the user who
I am designing an application where I don't want the user to have to
If you are designing an application such that the user must answer several questions
I am designing an application and I have two ideas in mind (below). I
I'm designing an application that has two [three including administrators] user types: Buyers and
I'm designing an application that will benefit from having the user's Facebook friends suggested

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.