Jump to content

So I'm making a maze type of game for a school assignment, and I just can't get the maze portion to display correctly. Right now, I have this. I'm using a GridLayout of (20x15) but all it's displaying when I run it are only two icons organized vertically, any ideas?

    private void updateGamePanel() {
        for (int i = 0; i < 15; i++) {
            for (int j = 0; j < 20; j++) {
                if (!instance.isHidden(i,j)){
                    if (instance.isMazeWall(i,j)) {
                        add(wallImage);
                    }
                    else {
                        add(hiddenImage);
                    }
                }
                else {
                    add(hiddenImage);
                }
            }
        }
    }

wallImage and hiddenImage are both JLabels of icons.

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 18.3) | iPhone 15 (iOS 18.3.1) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
https://linustechtips.com/topic/753360-displaying-icons-using-gridlayout-java/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×