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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:58:30+00:00 2026-06-13T07:58:30+00:00

Right now I am trying to make it so that the connect 4 grid

  • 0

Right now I am trying to make it so that the connect 4 grid on the gui is always a 7×8 no matter what window size. I have been trying to set the button array with a setMaximumSize and it’s not working.

Here is the code that sets the JButton array

void ResetGame()
        {

            JLabel label = new JLabel("Click a column to drop piece");



            for(int r=0;r<gameBoard.length;r++)
            {
                java.util.Arrays.fill(gameBoard[r],0,gameBoard[r].length,'0');



                //loop through board columns
                for(int c=0;c<gameBoard[r].length;c++)
                {
                    gameButtons[r][c]= new JButton(empty);
                    panel.add(gameButtons[r][c]);
                    gameButtons[r][c].setPreferredSize(new Dimension(70,70));
                    //Allows buttons to be arranged as grid.
                    GridLayout grid = new GridLayout(0,8);
                    //Sets into grid.
                    gameButtons[r][c].setLayout(grid);
                    gameButtons[r][c].setMaximumSize(new Dimension(0,10));

                }
                panel.add(label); 



            }
            // loop through array setting char array back to ' ' and buttons array back to empty pic
            // reset currentPlayer and numMoves variables
        }

Just in case I’ll also include the window creation method here.

public void CreateWindow()
        {
            //Sets window title and create window object.
            JFrame aWindow = new JFrame("Connect Four");
            //Set window position and size
            aWindow.setBounds(200,100,600,800);
            //What close button does.
            aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Make window visible.
            aWindow.setVisible(true);
            //Sets content area to work with stuff.
            aWindow.setContentPane(panel);
             //Gets content pane.
            Container content = aWindow.getContentPane();



        }
  • 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-13T07:58:32+00:00Added an answer on June 13, 2026 at 7:58 am

    setMaximumSize() puts a bound on how large something can be. Depending on what you are using for a layout manager you want either setPreferredSize() or setSize().

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

Sidebar

Related Questions

I always use auto_increment when making tables. Right now I'm trying to make a
right now im trying to make a function that checks to see if the
I am just messing around trying to make a game right now, but I
I'm trying to make Gzip compression work on xampp, right now this is in
I am trying to make Custom RelativeLayout which can scale and scroll. Right now
I'm learning smalltalk right now and am trying to make a very simple program
So, the query I'm trying to make looks like this right now: SELECT `jid`,
Okay I've been trying to figure this out for a while now. I have
Right now I am trying to create a producer/consumer thread, the producer thread goes
Right now I am trying to solve Project Euler 71 . Consider the fraction,

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.