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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:12:48+00:00 2026-05-22T18:12:48+00:00

I am making a monopoly game in Java and for some reason I cant

  • 0

I am making a monopoly game in Java and for some reason I cant seem to get this JFrame popup to refresh. When I click the button, the popup will appear, but when I close it and click it again later on it the game, it continues to show the features of the 1st JFrame. I assume that a totally new JFrame is created every time you click the button, but I cant seem to refresh the content. How do I fix this?

final static JButton tradeButton = new JButton("Click to Trade Property");
tradeButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent arg0){
                final JPanel tradePanelcombo = new JPanel();
                for(int x = 1; x< Player.Props.size(); x++)
                {
                    if(x != Player.CurrentPlayer)
                    {
                        ArrayList<Property> props = Player.Props.get(x);
                        ArrayList<String> propnames = new ArrayList<String>();
                        for(Property prop : props)
                        {
                            propnames.add(prop.getName());
                        }
                        String[] strings = new String[propnames.size()];
                        for (int y = 0; y<propnames.size(); y++)
                        {
                            strings[y] = propnames.get(y);
                        }
                        JLabel confirmLabel = new JLabel("Player :" + x);
                        JComboBox petList = new JComboBox(strings);
                        petList.setPreferredSize(new Dimension(100, 150));

                        tradeFrame.add(confirmLabel);
                        tradePanelcombo.add(petList);
                    }
                }
                tradeFrame.add(tradePanelcombo, BorderLayout.PAGE_END);
                tradeFrame.setPreferredSize(new Dimension(500,500));

                tradeFrame.setResizable(true);
                tradeFrame.pack();
                tradeFrame.setVisible(true);
            }
        });
  • 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-22T18:12:49+00:00Added an answer on May 22, 2026 at 6:12 pm

    It appears to me that a new frame and components are created every time.

    So, if the frame doesn’t update, then I guess it would be because your Properties are not updated so the data added to the components doesn’t change.

    Edit:

    You need to create a new JFrame every time, or you need to remove all the old components from the frame before adding the new components.

    When you add a component to a BorderLayout, the previous component doesn’t get removed. So you actually have two components in the container. When Swing paints components it actually paints the components in the reverse order that they where added to the container (this is how Z-Ordering works).

    If you remove the setResizable() method, and then resize the frame I believe you should see the new components start to show given that they should increase in size as the frame size increases.

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

Sidebar

Related Questions

Im making a game in Java with a few other people but we are
Making a winform in C#,there are several buttons, Click the button to achieve the
Making a simple Java code for Blackjack and need some advice. OK I am
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
After making some changes in my models (eg. new field in a model and
Making a new shooter game here in the vein of Galaga (my fav shooter
Making a mobile friendly site, I have a single field and a submit button.
making a new jsp and got a mock-up from some analyst. Notice the sections
Making an uno game for a project. all 108 cards are located in a
Making .htaccess (mod_rewrite) work has been very difficult I already have this script for

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.