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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:12:47+00:00 2026-05-29T05:12:47+00:00

I am designing a Pizza Delivery simulator for a class project. My team and

  • 0

I am designing a Pizza Delivery simulator for a class project. My team and I have most of it done, but we are struggling with the GUI.

I need to be able to add items to the order. Each time I click the add item button, it creates a new AddItemPanel (a panel I created that extends JPanel), and adds it to the JScrollPane.

The problem I am running into is it will only add ONE AddItemPanel to the scrollPane. I am not sure if they are being hidden underneath the first one, or if I am just doing something stupid.

Here is the relevant code:

JPanel itemPanel = new JPanel(new GridLayout(0, 1));

JViewPort viewPort = new JViewport();
viewPort.setLayout(new GridLayout(0, 1)); // not sure if I need this line
JScrollPane scrollPane = new JScrollPane(viewPort);
itemPanel.add(scrollPane);

// other stuff

JButton addItemButton = new JButton("Add Item");
addItemButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        viewPort.add(new AddItemPanel());
        validate();
    }
});

So my questions are: Is this even possible with a JScrollPane? If so, how do I do it? If not, how would I accomplish something similar?

(PS. I have linked screen shots in case they are helpful in explaining.)

screen shot 1
screen shot 2

  • 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-29T05:12:48+00:00Added an answer on May 29, 2026 at 5:12 am

    You have to add a JPanel to the JScrollPane, then add the additional panels to that JPanel. The JScrollPanel can only manage one child.

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

Sidebar

Related Questions

I have been designing with jquery and using the jquery UI widgets .. but
Designing forms has always been fun, but getting them to send email on the
When designing user table what would be the must have fields from the security/user
When designing a collection class, is there any reason not to implement locking privately
When designing both the domain-model and class-diagrams I am having some trouble understanding what
for designing purposes i need to truncate all DB which has lots of FK's.
While designing applications it is a very good practice to have all the business
In designing class with multiple/nested has-a relationships, who should catch exceptions? I guess this
the designing.making/deploying/management of a distributed database? or do i need to buy the versions
I designing a polynomial class for one of my com sci courses , I

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.